From nobody@FreeBSD.org  Tue Mar  4 23:09:36 2014
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
	(using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by hub.freebsd.org (Postfix) with ESMTPS id 6B7F0C23
	for <freebsd-gnats-submit@FreeBSD.org>; Tue,  4 Mar 2014 23:09:36 +0000 (UTC)
Received: from cgiserv.freebsd.org (cgiserv.freebsd.org [IPv6:2001:1900:2254:206a::50:4])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.freebsd.org (Postfix) with ESMTPS id 574169E7
	for <freebsd-gnats-submit@FreeBSD.org>; Tue,  4 Mar 2014 23:09:36 +0000 (UTC)
Received: from cgiserv.freebsd.org ([127.0.1.6])
	by cgiserv.freebsd.org (8.14.8/8.14.8) with ESMTP id s24N9Zr0094693
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 4 Mar 2014 23:09:35 GMT
	(envelope-from nobody@cgiserv.freebsd.org)
Received: (from nobody@localhost)
	by cgiserv.freebsd.org (8.14.8/8.14.8/Submit) id s24N9Z4B094692;
	Tue, 4 Mar 2014 23:09:35 GMT
	(envelope-from nobody)
Message-Id: <201403042309.s24N9Z4B094692@cgiserv.freebsd.org>
Date: Tue, 4 Mar 2014 23:09:35 GMT
From: Kimo R <kimor79@yahoo.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Passing -P to daemon(8) doesn't spawn child in an external process
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         187265
>Category:       bin
>Synopsis:       Passing -P to daemon(8) doesn't spawn child in an external process
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    jh
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Mar 04 23:10:01 UTC 2014
>Closed-Date:    Fri May 09 16:04:22 UTC 2014
>Last-Modified:  Fri May 09 16:04:22 UTC 2014
>Originator:     Kimo R
>Release:        10.0-RELEASE
>Organization:
>Environment:
>Description:
The manpage for daemon(8) says that with the -P (write daemon's pid to a file) flag, the program is spawned in a child process. However, passing -P doesn't cause the program to actually spawn in a child process.
>How-To-Repeat:
daemon -P /tmp/foo.pid some_long_running_process
>Fix:
This patch checks if -P was given in the same place as the check for -p (and -r)

Patch attached with submission follows:

--- ./daemon.c.orig	2014-03-04 22:20:17.000000000 +0000
+++ ./daemon.c	2014-03-04 22:23:29.000000000 +0000
@@ -139,7 +139,7 @@
 	 * get SIGCHLD eventually.
 	 */
 	pid = -1;
-	if (pidfile != NULL || restart) {
+	if (pidfile != NULL || ppidfile != NULL || restart) {
 		/*
 		 * Restore default action for SIGTERM in case the
 		 * parent process decided to ignore it.


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->jh 
Responsible-Changed-By: jh 
Responsible-Changed-When: Sun Apr 6 16:14:05 UTC 2014 
Responsible-Changed-Why:  
Take. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=187265 
State-Changed-From-To: open->patched 
State-Changed-By: jh 
State-Changed-When: Sun Apr 6 16:38:36 UTC 2014 
State-Changed-Why:  
Committed in r264194. Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=187265 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/187265: commit references a PR
Date: Sun,  6 Apr 2014 16:35:52 +0000 (UTC)

 Author: jh
 Date: Sun Apr  6 16:35:49 2014
 New Revision: 264194
 URL: http://svnweb.freebsd.org/changeset/base/264194
 
 Log:
   Fork a child process and wait until the process terminates when the -P
   option is specified. This behavior is documented on the manual page.
   
   PR:		bin/187265
   Submitted by:	Kimo R
   MFC after:	2 weeks
 
 Modified:
   head/usr.sbin/daemon/daemon.c
 
 Modified: head/usr.sbin/daemon/daemon.c
 ==============================================================================
 --- head/usr.sbin/daemon/daemon.c	Sun Apr  6 16:31:28 2014	(r264193)
 +++ head/usr.sbin/daemon/daemon.c	Sun Apr  6 16:35:49 2014	(r264194)
 @@ -139,7 +139,7 @@ main(int argc, char *argv[])
  	 * get SIGCHLD eventually.
  	 */
  	pid = -1;
 -	if (pidfile != NULL || restart) {
 +	if (pidfile != NULL || ppidfile != NULL || restart) {
  		/*
  		 * Restore default action for SIGTERM in case the
  		 * parent process decided to ignore it.
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/187265: commit references a PR
Date: Fri,  9 May 2014 15:55:48 +0000 (UTC)

 Author: jh
 Date: Fri May  9 15:55:45 2014
 New Revision: 265781
 URL: http://svnweb.freebsd.org/changeset/base/265781
 
 Log:
   MFC r264194:
   
   Fork a child process and wait until the process terminates when the -P
   option is specified. This behavior is documented on the manual page.
   
   PR:		bin/187265
 
 Modified:
   stable/10/usr.sbin/daemon/daemon.c
 Directory Properties:
   stable/10/   (props changed)
 
 Modified: stable/10/usr.sbin/daemon/daemon.c
 ==============================================================================
 --- stable/10/usr.sbin/daemon/daemon.c	Fri May  9 14:35:07 2014	(r265780)
 +++ stable/10/usr.sbin/daemon/daemon.c	Fri May  9 15:55:45 2014	(r265781)
 @@ -139,7 +139,7 @@ main(int argc, char *argv[])
  	 * get SIGCHLD eventually.
  	 */
  	pid = -1;
 -	if (pidfile != NULL || restart) {
 +	if (pidfile != NULL || ppidfile != NULL || restart) {
  		/*
  		 * Restore default action for SIGTERM in case the
  		 * parent process decided to ignore it.
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: jh 
State-Changed-When: Fri May 9 16:04:21 UTC 2014 
State-Changed-Why:  
Fixed in head and stable/10. Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=187265 
>Unformatted:
