TNG / inet_aton

Steve Langasek vorlon at netexpress.net
Thu Jan 13 23:23:48 GMT 2000


On Fri, 14 Jan 2000, Luke Kenneth Casson Leighton wrote:

> can someone evaluate this, i have no idea if it's correct [the fork()
> bit].

I can't speak for Solaris, and I'm not sure what POSIX says about waitpid(),
but this would not be correct in the Linux implementation of waitpid().  Under
Linux, the first argument to waitpid() is typically the pid of the process
that you're waiting for (it can take other values with special meaning).

-Steve Langasek
postmodern programmer

> > One thing I did change in the code, which I *think* fixed a problem with
> > printing ... I noticed errors to the effect of "Running command
> > 'lpstat -o<queue>' returned -1". I traced this to the following bit of
> > lib/smbrun.c :

> >         if ((pid=fork())) {
> >                 int status=0;
> >                 /* the parent just waits for the child to exit */
> >                 if (sys_waitpid(pid,&status,0) != pid) {
> >                         DEBUG(2,("waitpid(%d) : %s\n",pid,strerror(errno)));
> >                         return -1;
> >                 }
> >                 return status;
> >         }

> > Bearing in mind that I know nothing about fork()ing, I had a look at this,
> > and waitpid(2), and decided that it was waiting on the wrong process - it
> > should be waiting on *children* of the main process to exit, not children
> > of the *child*. I changed it to:

> >                 if (sys_waitpid(getpid(),&status,0) != pid) {

> > and the error went away! And I could print! As I say, I'm not familiar with
> > this sort of code, so I could be completely wrong, and just fluked getting
> > the print jobs though :)

> > Anyway, I hope this helps ... the server is Solaris 7, and I'm using SYSV
> > printing with "printcap name = lpstat".




More information about the samba-technical mailing list