fix for PR#26135, smbmount doesnt return exit codes after daemonizing (v2.2.7)

Scott Hammond sehammond at
Tue Dec 10 00:13:00 GMT 2002

I went ahead and fixed my own bug report, #26135. 
smbmount.c doesnt return exit codes correctly after it
daemonizes.  Most errors occur from simple things,
wrong password, cant connect, etc, so "echo $?" after
the smbmount command returns 1.  However if smbmnt
fails (which is called after smbmount daemonizes),
then the exit code is lost, and "echo $?" returns 0. 
e.g. if the target directory is not owned by the user,
smbmnt fails, but the exit code is lost.

from smbmount.c, daemonize():

if (child_pid > 0) {
     while( 1 ) {
          j = waitpid( child_pid, &status, 0 );
          if( j < 0 ) {
               if( EINTR == errno ) {
               status = errno;
#         if (WIFEXITED(status)) {
#              status = WEXITSTATUS(status);
#         }
     /* If we get here - the child exited with some
error status */

I added the part with the #'s.  Apparently exit()
doesnt like status until its been fixed up by the
WEXITSTATUS() macro (man page for waitpid says
WEXITSTATUS() is invalid if WIFEXITED is 0, so I added
that as well).  Now the error code from smbmnt should
be returned correctly by smbmount.

here's the diff for smbmount.c:
<                       if (WIFEXITED(status)) {
<                               status =
<                               }

fyi, Im running linux slackware 8.1 with gcc 3.2.


Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.

More information about the samba-technical mailing list