Bug 4871 - Solaris init script stop fails when killing smbd
Solaris init script stop fails when killing smbd
Status: NEW
Product: Samba 3.0
Classification: Unclassified
Component: Packaging
All Solaris
: P3 normal
: none
Assigned To: Samba Bugzilla Account
Samba QA Contact
Depends on:
  Show dependency treegraph
Reported: 2007-08-09 13:13 UTC by Peter Lyons
Modified: 2009-04-04 08:02 UTC (History)
1 user (show)

See Also:

Fix this bug and support Solaris zones (1.12 KB, patch)
2008-09-09 20:31 UTC, SATOH Fumiyasu
no flags Details
Revised patch (1.52 KB, patch)
2009-02-05 08:19 UTC, SATOH Fumiyasu
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Lyons 2007-08-09 13:13:24 UTC
When the solaris version of the smb init script is run with the "stop" argument, it works but exits with a nonzero exit code.  This happens because it runs /usr/bin/ps and greps for the smbd process, but since there are now 2 processes, the code (which looks to expect only 1 process) kills both the parent and child process. However, killing the parent kills the child, so when /usr/bin/kill gets to the child pid, it is no longer running, so it returns an error code and prints "No such process".

To fix this, you can run the /usr/bin/ps command through sort -nr and head -1 and/or consider using the PID files.
Comment 1 Björn Jacke 2007-08-21 04:06:25 UTC
the "sort -nr" way is *bad* because after a overrun of the pid table the child processes will have lower pids than the parent process.
Comment 2 SATOH Fumiyasu 2008-01-15 00:01:04 UTC
Proposed patch:

--- samba.init.master.dist	2005-07-28 22:19:54.000000000 +0900
+++ samba.init.master	2008-01-15 15:00:08.000000000 +0900
@@ -11,9 +11,7 @@
 killproc() {            # kill the named process(es)
-        pid=`/usr/bin/ps -e |
-             /usr/bin/grep -w $1 |
-             /usr/bin/sed -e 's/^  *//' -e 's/ .*//'`
+        pid=`/usr/bin/pgrep -x -P 1 $1`
         [ "$pid" != "" ] && kill $pid
Comment 3 SATOH Fumiyasu 2008-09-09 20:31:12 UTC
Created attachment 3547 [details]
Fix this bug and support Solaris zones
Comment 4 SATOH Fumiyasu 2009-02-05 08:19:02 UTC
Created attachment 3925 [details]
Revised patch