This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
gcc 3 problem on sigaction and system
- From: Kun Wei <weikun at caltech dot edu>
- To: gcc at gcc dot gnu dot org, gcc-help-help at gcc dot gnu dot org
- Date: Fri, 18 Jul 2003 15:16:35 -0700
- Subject: gcc 3 problem on sigaction and system
- Organization: Caltech
Hi;
I notice since gcc 3, the return value of system() doesn't work
correctly. The following code will return 0 or -1 randomly, please help
me how to solve this problem because I need to check if return value is
-1 to make sure system call is fine or not.
#include <signal.h>
main()
{
struct sigaction v_sig;
#if !defined(linux)
v_sig.sa_flags = SA_NOCLDWAIT;
#else
v_sig.sa_handler = SIG_IGN;
#endif
sigaction(SIGCHLD, &v_sig, 0);
printf("return %d\n", system("ls -l > /dev/null"));
return (0);
}
Thanks a lot
Kun