Running C Program in Background help
I have recently registered for a free shell account so that i can use it to test C Programs from any Windows PC using the net. Now the problem is that i have made a server program which needs to run in the background, but when i try doing that using & its not working,the program starts running and even pressing Ctrl+Z it wont go to the background! Any idea whats wrong?
|
Start it this way:
nohup program & Or use screen. |
i am using it like this:
./programObject& And whats screen?? |
You need a space between the prog name and the '&'.
Using nohup as well ensures it'll keep running if you logout, otherwise it's still 'attached' to your terminal, even though it's in background mode. IOW, do as per kotnik's example |
Have you tried forking the program? I'm not sure if that's the proper terminology, as I'm not a C or C++ programmer. The method I'm referring to goes like this:
1. Start Program1. 2. Spawn a child process for the main algorithm. 3. The parent process dies, as it is finished, and the child process does what it's supposed to do. |
ok this is whats happeneing:
When i run the program with this command: ./ProgramObject<SPACE>& the program starts running on screen and does not go to the background even by pressing Ctrl+Z. And using nohup also does not make any difference. But the program is running fine in my college PC which runs Linux. So is the problem with my Shell Account? |
If a program produces output while it runs, it will most definitely print the output to the shell is was run from.
To get rid of the output, you need to pipe it to a different source. Code:
$ ./ProgramObject & >> ProgramObject.log #For debugging |
Quote:
|
All times are GMT -5. The time now is 07:10 PM. |