Alternatives to system() function in a C++ application?
From: min (minjie_at_excite.com)
Date: 26 Jul 2005 07:33:57 -0700
We have a C++ application running on Linux that contains lots of
system() function calls, such as the following:
system ("./kill_autolog 2>/dev/null");
system ("/usr/bin/konsole --noclose -T RPCLOG --vt_sz 180x15 -e
./autolog 2> /dev/null &");
sprintf (command, "wc -l ./workfile1 > ./workfile2");
system ("rm ./workfile1"); // remove the temporary workfiles
system ("rm ./workfile2");
kill_autolog is a Perl script, while rm or wc are Linux shell commands.
There are lots of similar calls like this. They work fine except that
when we tried to debug the application with KDevelop or GDB, the
debugger got totally lost after entering the system() function, meaning
it never comes back to the breakpoint even if we set up a breakpoint
immediately after the system() statement. We are thinking of replacing
the system() function with some other function(s), or find a way not to
let GDB get lost. I haven't succeeded in either. Please help. Thanks.