fok() execve() -> No child processes

victor cruceru victor.cruceru at gmail.com
Thu Sep 8 13:54:32 PDT 2005


Well, I suppose that execve is successful. if not you should call
_exit() instead of exit() in the child process (you should not return
from e_x_e_c if the exec fails)
Also your application should not  ignore SIGCHLD.
See man vfork and especially man wait. 
victor cruceru

On 9/8/05, erkan kolemen <erkankolemen at yahoo.com> wrote:
> i tried and still same error.
> 
> thanks.
> 
> --- victor cruceru <victor.cruceru at gmail.com> wrote:
> 
> > Try to replace vfrork with fork and check if you'll
> > get the same behavior.
> > victor cruceru
> >
> >
> > On 9/8/05, erkan kolemen <erkankolemen at yahoo.com>
> > wrote:
> > > Following code fails. I debugged it and saw that:
> > it
> > > produces "No child processes" error while wait().
> > >
> > > is it possible, parent still is not start to wait
> > but
> > > child finished. After that CPU schedules parents.
> > It
> > > try to start wait but child has finished.
> > >
> > > is it possible... What can i do for that?
> > >
> > > static int e_x_e_c(char *cmd[])
> > > {
> > >        pid_t pid;
> > >        int stat;
> > >
> > >        switch((pid = vfork())) {
> > >                case -1:
> > >                        syslog(LOG_ERR, "fork: %s",
> > > strerror(errno));
> > >                        return -16;
> > >                        break;
> > >                case 0:
> > >                        if(execve(cmd[0], cmd,
> > NULL)
> > > == -1) {
> > >                                syslog(LOG_ERR,
> > > "execve: %s", strerror(errno));
> > >                                return -15;
> > >                        }
> > >                        break;
> > >                default:
> > >                        if (wait(&stat) == -1) {
> > >                                slog(1, LOG_ERR);
> > >                                return -14;
> > >                        }
> > >
> > >                        if (WIFSIGNALED(stat)) {
> > >                                syslog(LOG_NOTICE,
> > "%s
> > > is signalled", cmdline[0]);
> > >                                return -13;
> > >                        }
> > >
> > >                        if (WIFSTOPPED(stat)) {
> > >                                syslog(LOG_NOTICE,
> > "%s
> > > is stopped", cmdline[0]);
> > >                                return -12;
> > >                        }
> > >
> > >                        if (WIFEXITED(stat))
> > >                                return
> > > WEXITSTATUS(stat);
> > >                        break;
> > >        }
> > >        return -11;
> > > }
> > >
> > >
> > >
> > >
> > >
> > >
> >
> ______________________________________________________
> > > Click here to donate to the Hurricane Katrina
> > relief effort.
> > > http://store.yahoo.com/redcross-donate3/
> > > _______________________________________________
> > > freebsd-hackers at freebsd.org mailing list
> > >
> >
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> > > To unsubscribe, send any mail to
> > "freebsd-hackers-unsubscribe at freebsd.org"
> > >
> >
> 
> 
> 
> 
> 
> ______________________________________________________
> Click here to donate to the Hurricane Katrina relief effort.
> http://store.yahoo.com/redcross-donate3/
>


More information about the freebsd-hackers mailing list