signal handling in child process.

From: micheel drippee (micheel_d23_at_yahoo.com.tr)
Date: 10/30/05

  • Next message: Doug Barton: "Re: tcp services (ssh,ftp) does not work"
    Date: Sun, 30 Oct 2005 20:10:17 +0200 (EET)
    To: freebsd-hackers@freebsd.org
    
    

    hello,

    i have a daemon program and installed a
    signal_handler() function for it. from signal_handler:

    case SIGCHLD:
      if ((wait(&status)) == -1) return;
      if (WIFSIGNALED(status)) return;
      if (WIFSTOPPED(status)) return;
      if (WIFEXITED(status)) return;
      break;

    in child process i am doing a fork() and then execve.

    switch((pid = vfork())) {
    case -1:
      error...
    case 0:
      execve();
    default:
      if (wait(&stat) == -1) {
        syslog(LOG_ERR, "wait: %s", strerror(errno));
        return -1;
      }
    }

    The problem is that: when the executing program is
    exited wait() returns error. 'No child processes'

    I determined that, my signal handler catchs SIGCHLD
    when the process finish. And then waits it. So the
    child process cannot wait its own child.

    How can i solve this problem? I found a solution but i
    am not sure if it is best way.

    I ignore SIGCHLD in child before execve.

    signal(SIGCHLD, SIG_IGN);

    What is your comments.

    thank you..

    -mch

                    
    ___________________________________________________________________
    Yahoo! kullaniyor musunuz? http://tr.mail.yahoo.com
    Istenmeyen postadan biktiniz mi? Istenmeyen postadan en iyi korunma
    Yahoo! Posta’da
    _______________________________________________
    freebsd-hackers@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
    To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"


  • Next message: Doug Barton: "Re: tcp services (ssh,ftp) does not work"

    Relevant Pages

    • Re: AIX process hogging CPU
      ... Normally, when the child process exits, parents SIGCHLD ... handler gets called after which the child thread returns and the CPU ... int fildes; ...
      (comp.unix.aix)
    • [PATCH] fix handling of SIGCHILD from reaped child
      ... any pending SIGCHLD signal shall be cleared unless ... the status of another child process is available. ... * This function clears pending SIGCHLD from the reaped child. ... More majordomo info at http://vger.kernel.org/majordomo-info.html ...
      (Linux-Kernel)
    • Re: [PATCH] fix handling of SIGCHILD from reaped child
      ... SUSv3 says ... if waitor waitpid() return because the status of a ... any pending SIGCHLD signal shall be cleared unless ... the status of another child process is available. ...
      (Linux-Kernel)
    • Re: child pid
      ... termination in a array and the time in other. ... indicates that at least one child process has terminated. ... >> how do you get the child PID in a signal handler for the SIGCHLD signal? ... > (On some systems with optional Real-Time Signals, there is a way to get more ...
      (comp.unix.programmer)