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 ...
- 05-18-2011 #1Just 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.
- 05-20-2011 #2Linux Guru
- 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!
- 05-20-2011 #3Just Joined!
- Join Date
- Apr 2011
- Posts
- 19
Long shot
Are you requesting any input in your program? It may suspending itself waiting for
input.
- 05-20-2011 #4Just 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)
- 05-20-2011 #5Linux 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.:
This should give a terminal prompt. Then start up your program as normal, whatever it's called:Code:screen -S myScreen
Then detacth from the terminal by pressing [Ctrl+Alt]+[D].Code:myprog
You can list your running screen sessions by doing:
This will return something like:Code:screen -ls
To reattach to your terminal, you can do:Code:28920.test (Detached) 31121.myScreen (Detached)
hthCode:screen -r 31121


Reply With Quote