Demo entry 6356536

wait

   

Submitted by anonymous on Apr 19, 2017 at 05:40
Language: C. Code size: 594 Bytes.

do{
     w = waitpid(cpid, &wstatus, WUNTRACED | WCONTINUED);
     if (w == -1){
          perror("waitpid");
          exit(EXIT_FAILURE);
     }

     if (WIFEXITED(wstatus)) {
         printf("exited, status=%d\n", WEXITSTATUS(wstatus));
     } else if (WIFSIGNALED(wstatus)) {
         printf("killed by signal %d\n", WTERMSIG(wstatus));
     } else if (WIFSTOPPED(wstatus)) {
         printf("stopped by signal %d\n", WSTOPSIG(wstatus));
     } else if (WIFCONTINUED(wstatus)) {
         printf("continued\n");
     }
} while (!WIFEXITED(wstatus) && !WIFSIGNALED(wstatus));

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).