Michael H. Warfield
mhw at wittsend.com
Sun Jan 31 16:55:47 GMT 1999
Paul enscribed thusly:
> This is regarding the userland smbfs utils included with Samba 2.0
> for use with Linux kernel 2.1 and 2.2.
> The other day I noticed that smbmount processes don't die when the
> mounted share is unmounted with either smbumount (as user) or umount (as
> root). I enabled smbfs debugging in the kernel and found that the kernel
> was sending its signals to the daemon's parent. Upon examining the
> smbmount code I found that smbmount mounts the share before daemonizing.
> Thus the kernel thinks that the parent smbmount process is handling
> things, and knows nothing about the daemon. So when the share is unmounted
> the kernel sends SIGTERM to the wrong PID, and the daemon just sits there.
> What's worse is the daemon wont be able to help the kernel if it needs
> something (the kernel sends SIGUSR1).
> There is a comment in smbmount's code explaining why the mount is
> done first:
> * Create the background process after trying the mount.
> * to avoid race conditions with automount and other processes.
> What exactly causes this race? Does the problem lie in the chance of the
> parent returning before the deamon finishes the mount? If so, wouldn't it
> be possible for the parent to pause() and wait for the daemon to send it
> SIGTERM after it has completed the mount and the kernel would then have
> the proper PID? Or is it something else? Please forgive me for any
> ignorance, I'm fairly new to this.
The race involves autofs. Autofs runs too soon because the parent
process exits and tries to run before the mount is complete. The result
is three or four mount attempts (all but the first failing because the
mount point is busy) plus some really weird stuff up in user land.
Actually, what it needs to do is waid_pid on the child and intercept
a signal back from the child. The wait_pid is to intercept any conditions
which would require returning an error and the signal is the normal exit
> Paul Laufer
Michael H. Warfield | (770) 985-6132 | mhw at WittsEnd.com
(The Mad Wizard) | (770) 925-8248 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0xDF1DD471 | possible worlds. A pessimist is sure of it!
More information about the samba-technical