I hacked together this little C program from this other little c program. Basically acts as an execution wrapper that lets you fork() and detach and run a command in the background with a pidfile and log file for program output. So far I havent had any problems with it… but then I’m not a true C guy so any input is welcomed.
If you want to redirect all the output of the program to a file, you don't need to fork yet another process with <code>popen()</code>:
freopen( "/path/to/logfile", "a", stdout);
freopen( "/path/to/logfile", "a", stderr);
exec[l|v]p( command, … );
Thus you can get both stdout and stderr, you don't spawn another process and you don't open and close the log file on every 1024 chars. Of course, the error checking was omitted 🙂
Hey man, it's Nu!! Are the IRC's still in one piece anywhere? Lookin' to get ahold of a few people, Aly, EE, etc…
Stop by and leave a comment on my site (now: WinBreak.com) or just look me on on a messenger service:
AIM: RotatingFlavors
MSN: [email protected]