Find the answer to your Linux question:
Results 1 to 5 of 5
hi, I am doing a program that reads data from a gps and some other devices and writes some files with all the information. When I run it normally it ...
  1. #1
    Just Joined!
    Join Date
    May 2010
    Location
    Madrid
    Posts
    21

    proccess does not write to disk while it is on background

    hi,
    I am doing a program that reads data from a gps and some other devices and writes some files with all the information.
    When I run it normally it works fine, but if I run the program in the background (with the ampersand) files are not created until I bring it to foreground or close it.

    I am confused, the program should run the same way with and without the ampersand.
    Does anyone know what it is going on and how to fix it???

    any help will be gratefully welcome
    J.

    (could it be that the main process that creates all the threads does not create them when it is executed in background? it seems like if the program is stopped until I take it to the foreground)
    Last edited by occam25; 05-18-2011 at 05:04 PM.

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    How are you reading/writing the data? What language(s) are you using?
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Just Joined!
    Join Date
    Apr 2011
    Posts
    19

    Long shot

    Are you requesting any input in your program? It may suspending itself waiting for
    input.

  4. #4
    Just Joined!
    Join Date
    May 2010
    Location
    Madrid
    Posts
    21
    Hi again,
    I am programing in C and using the standar functions fopen, fwrite and fflush to write the files.

    The program stops before any input request. I send some screenshots.

    1. Normal start of the program, without the &.


    2. Running the program on the background, with &. It seems to get stucked.


    3. Then, when I press enter it says that the process is "Detenido" (that means Stopped) -> I dont understand why it stops


    4. When I take it to foreground the process continue


    I dont understad why it does not run the same way. (Now I have demoniced the program and it seems to work fine)

  5. #5
    Linux Guru
    Join Date
    May 2011
    Posts
    1,843
    I recommend you try the screen utility for this type of problem.

    Start it with your own label, e.g.:
    Code:
    screen -S myScreen
    This should give a terminal prompt. Then start up your program as normal, whatever it's called:
    Code:
    myprog
    Then detacth from the terminal by pressing [Ctrl+Alt]+[D].

    You can list your running screen sessions by doing:
    Code:
    screen -ls
    This will return something like:
    Code:
            28920.test      (Detached)
            31121.myScreen      (Detached)
    To reattach to your terminal, you can do:
    Code:
    screen -r 31121
    hth

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...