This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gcc 3 problem on sigaction and system


> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]