TNG / inet_aton

Cole, Timothy D. timothy_d_cole at md.northgrum.com
Fri Jan 14 15:43:51 GMT 2000


> -----Original Message-----
> From:	Luke Kenneth Casson Leighton [SMTP:lkcl at samba.org]
> Sent:	Thursday, January 13, 2000 18:08
> To:	Multiple recipients of list SAMBA-NTDOM
> Subject:	Re: TNG / inet_aton 
> 
> can someone evaluate this, i have no idea if it's correct [the fork()
> bit].
> 
	The original code was correct.  Kind of.  The return value of fork()
is:

	         0 - in the child process
	 chlid pid - in the parent process

	or:

	        -1 - error; no child process forked

	Normally the way I see this handled is:

	 pid = fork();
	 switch (pid) {
	   case 0;
	         /* do child things */
	  	      break;
	   case -1:
	  	      /* handle error */
	  	      break;
	   default:

	 }

> also, iain, give me more info.  what is the workstation name.  which is
> the samba server.  which log file has the trust account error message?
> 
> etc.
> 
> On Thu, 13 Jan 2000, Iain MacDonnell wrote:
> 
> > 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) {
> 
	Since this code executes in the parent, getpid() will be the pid of
the parent process -- probably not quite what you had in mind.  This should
actually fail, causing sys_waitpid() to return (pid_t)-1, and set errno to
ECHILD.

	I have no idea why it doesn't fail, or why it returns pid.  (it may
be that under Solaris, waitpid(getpid(), &status, 0) is equivalent to
wait(&status), but I seriously doubt that assumption is portable)




More information about the samba-ntdom mailing list