From owner-freebsd-rc@FreeBSD.ORG Sun Jul 18 04:02:19 2010 Return-Path: Delivered-To: rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EA30E1065676; Sun, 18 Jul 2010 04:02:18 +0000 (UTC) (envelope-from jhellenthal@gmail.com) Received: from mail-iw0-f182.google.com (mail-iw0-f182.google.com [209.85.214.182]) by mx1.freebsd.org (Postfix) with ESMTP id 9B42E8FC0C; Sun, 18 Jul 2010 04:02:18 +0000 (UTC) Received: by iwn35 with SMTP id 35so4383147iwn.13 for ; Sat, 17 Jul 2010 21:02:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:date:from:to:cc :subject:in-reply-to:message-id:references:user-agent :x-openpgp-key-id:x-openpgp-key-fingerprint:mime-version :content-type; bh=z1cSO9xmHJL5KiQF2E5CV5Wve2m/C2Fbc2jHvk1ghsM=; b=Q2rneEIxzR45381G+35yWXhvVD9MgRN6vAGWfCx0jkyFttjtnVB1MCMmgb1nPEiCld 2QqQncVtzhlr3/95BiZpZGVQPF6HBuEQgyHndjtO3rw89x72d7cFLWslCZRLh0wTGPG2 0AeRp4/PmNuCxNFsLjMjndfqHjVTj0uLc1UmI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:x-openpgp-key-id:x-openpgp-key-fingerprint:mime-version :content-type; b=k2Ic9F32LkMNefmEqlXKkbu7zLO+97twNgbjbW6Ku7yjsppSYgz/ZXeq+Q+5n66sjo ZGx/T2VNHHdfgpp9S8w2wmrZs1QSrvAE9+BYtdKDxyrz5E/qrMa30PE9M/CzFOdgCst9 bhUD+1l3x3UQI8XfIzkIpOP/LE1g7zkMdpLZA= Received: by 10.231.32.200 with SMTP id e8mr3178205ibd.66.1279425737945; Sat, 17 Jul 2010 21:02:17 -0700 (PDT) Received: from centel.dataix.local ([99.181.132.254]) by mx.google.com with ESMTPS id e8sm17955140ibb.20.2010.07.17.21.02.16 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 17 Jul 2010 21:02:17 -0700 (PDT) Sender: "J. Hellenthal" Date: Sun, 18 Jul 2010 00:02:09 -0400 From: jhell To: Ed Schouten In-Reply-To: Message-ID: References: <20100717105658.GV1742@hoeg.nl> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) X-OpenPGP-Key-Id: 0x89D8547E X-OpenPGP-Key-Fingerprint: 85EF E26B 07BB 3777 76BE B12A 9057 8789 89D8 547E MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: ports@freebsd.org, rc@freebsd.org Subject: Re: General note on rc scripts and daemonizing X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Jul 2010 04:02:19 -0000 On Sat, 17 Jul 2010 18:43, jhell wrote: In Message-Id: > > On Sat, 17 Jul 2010 06:56, Ed Schouten wrote: > In Message-Id: <20100717105658.GV1742@hoeg.nl> > >> Hello port maintainers, >> >> I think I'd better send an email about this to ports@, because I've seen >> it in various places and it is getting a bit tiresome to mail all port >> authors individually. >> >> I've seen various cases in the past where people write rc scripts that >> do the following: >> >> command="/usr/local/bin/dog" >> command_args="--bark > /dev/null 2>&1 &" >> >> So in this case `dog --bark' doesn't daemonize itself, so the & is >> sufficient here, right? Well, it is not. :-) The point is that we simply >> tell the kernel to redirect stdout/stderr and run it in the background. >> It doesn't tell the kernel that the process should run in a separate >> session (see getsid(2)/setsid(2)). >> >> This has various implications. The most important one I can think of, is >> that the daemon can still do open("/dev/tty", ...) if it wants and spam >> your TTY, even if the daemon is running as user `nobody'. This also >> means that if you run the rc script from within a pseudo-terminal, it >> can never actually destroy the pseudo-terminal for you, because maybe >> the daemon is interested in using it. >> >> Below is the output of `pstat -t' on one of my systems, where I decided >> to fire up MySQL: >> >> | LINE INQ CAN LIN LOW OUTQ USE LOW COL SESS PGID STATE >> | ... >> | pts/11 0 0 0 0 0 0 0 0 82711 0 G >> >> The kernel actually wants to clean up this pseudo-terminal (state = G), >> but it is prevented from doing so. It will only clean it up by the time >> MySQL is shut down. >> >> So how can this be solved? We already have a tool in base called >> daemon(8). It is simply a wrapper around daemon(3) (which calls >> setsid(2), which you can use to daemonize processes. So the next time >> you write an rc script and need to daemonize something which cannot do >> it by itself, please think of the kittens. ;-) >> >> [ CCing this to rc@. Maybe we should add some kind of built-in >> functionality to call daemon(8)? ] >> > > Hi Ed, > > Very nice note as well a very good practice. I have noticed this for > a while but never looked into it more so I could not really put a name to it. > Thanks. > > > Off topic of ports: > > While this subject is hot, I have been doing the following on an > updated system, current version of xterm on two up-to-date stable/8 machines. > I am having trouble narrowing down the cause of the controlling pseudo > terminal freezing until ^C is hit after using daemon(1) to spawn ssh in the > background to start a remote xterm. > > > # Open a pseudo terminal [pts/13] > xterm (the culprit) > > # Mix up the terminal a little so its not so fresh. [pts/13] > ls -l > > # Use daemon to start a remote xterm through ssh. [pts/13] > daemon ssh -M remotehost xterm > > At this stage the remote x11 forwarded xterm opens and works properly "set > this terminal aside, its not the problem". > > # On the originating pseudo terminal [pts/13] > su - > Password: ********** > host# _ > > After that you should have to hit ^C to proceed to the next bang line or > enter anything for that matter. > > Any clue at what might be going on or any more information that I could > provide to help deduce this ?. > > > Regards, > > Also another use with the case above. Running top(1) instead of su(1) you should see the same symptoms. I should probably also state that using the -f flag to ssh(1) without daemon(1) does not exhibit any of these symptoms. Regards, -- jhell,v From owner-freebsd-rc@FreeBSD.ORG Mon Jul 19 11:07:04 2010 Return-Path: Delivered-To: freebsd-rc@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CC176106566C for ; Mon, 19 Jul 2010 11:07:04 +0000 (UTC) (envelope-from owner-bugmaster@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id B006C8FC08 for ; Mon, 19 Jul 2010 11:07:04 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o6JB74AT065818 for ; Mon, 19 Jul 2010 11:07:04 GMT (envelope-from owner-bugmaster@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o6JB7464065816 for freebsd-rc@FreeBSD.org; Mon, 19 Jul 2010 11:07:04 GMT (envelope-from owner-bugmaster@FreeBSD.org) Date: Mon, 19 Jul 2010 11:07:04 GMT Message-Id: <201007191107.o6JB7464065816@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: gnats set sender to owner-bugmaster@FreeBSD.org using -f From: FreeBSD bugmaster To: freebsd-rc@FreeBSD.org Cc: Subject: Current problem reports assigned to freebsd-rc@FreeBSD.org X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Jul 2010 11:07:04 -0000 Note: to view an individual PR, use: http://www.freebsd.org/cgi/query-pr.cgi?pr=(number). The following is a listing of current problems submitted by FreeBSD users. These represent problem reports covering all versions including experimental development code and obsolete releases. S Tracker Resp. Description -------------------------------------------------------------------------------- o conf/148656 rc rc.firewall(8): {oip} and {iip} variables in rc.firewa o conf/147685 rc [rc.d] [patch] new feature for /etc/rc.d/fsck o conf/147444 rc [rc.d] [patch] /etc/rc.d/zfs stop not called on reboot o conf/146053 rc [patch] [request] shutdown of jails breaks inter-jail o conf/145445 rc [rc.d] error in /etc/rc.d/jail (bad logic) o conf/145440 rc [rc.d] [patch] add multiple fib support (setfib) in /e o conf/145399 rc [patch] rc.d scripts are unable to start/stop programs o conf/145344 rc [patch] Fix kitchen sink approach for rc.d scripts ins o conf/145009 rc [patch] rc.subr(8): rc.conf should allow mac label con o conf/144213 rc [rc.d] [patch] Disappearing zvols on reboot o conf/143637 rc [patch] ntpdate(8) support for ntp-servers supplied by o conf/143085 rc [patch] ftp-proxy(8) rc(8) with multiple instances o conf/143084 rc [jail] [patch]: fix rc.d/jail creating stray softlinks o conf/142973 rc [jail] [patch] Strange counter init value in jail rc o conf/142434 rc [patch] Add cpuset(1) support to rc.subr(8) o conf/142304 rc rc.conf(5): mdconfig and mdconfig2 rc.d scripts lack e o conf/141909 rc rc.subr(8): [patch] add rc.conf.d support to /usr/loca o conf/141907 rc [rc.d] Bug if mtu (maybe others?) is set as first argu o conf/141678 rc [patch] A minor enhancement to how /etc/rc.d/jail dete o conf/141275 rc [request] dhclient(8) rc script should print something o conf/140440 rc [patch] allow local command files in rc.{suspend,resum o conf/140261 rc [patch] Improve flexibility of mdconfig2 startup scrip o conf/138208 rc [rc.d] [patch] Making rc.firewall (workstation) IPv6 a o conf/137629 rc [rc.d] background_dhclient rc.conf option causing doub o conf/137470 rc [PATCH] /etc/rc.d/mdconfig2 : prioritize cli parameter o conf/137271 rc [rc.d] Cannot update /etc/host.conf when root filesyst o conf/136875 rc [request] _flags appending o conf/136624 rc [rc.d] sysctl variables for ipnat are not applied on b o conf/135338 rc [rc.d] pf startup order seems broken [regression] o conf/134918 rc [patch] rc.subr fails to detect perl daemons o conf/134660 rc [patch] rc-script for initializing ng_netflow+ng_ipfw o conf/134333 rc PPP configuration problem in the rc.d scripts in combi o conf/134006 rc [patch] Unload console screensaver kernel modules if s o conf/133987 rc [rc.d] defaultroute broken with DHCP in some cases o conf/133890 rc [patch] sshd(8): add multiple profiles to the rc.d scr o conf/132483 rc rc.subr(8) [patch] setfib(1) support for rc.subr o conf/132476 rc [rc.d] [patch] add support setfib(1) in rc.d/routing o conf/128299 rc [patch] /etc/rc.d/geli does not mount partitions using o conf/127917 rc [patch] dumpon rejects on start with physmem>swap even o bin/126562 rc rcorder(8) fails to run unrelated startup scripts when o conf/126392 rc [patch] rc.conf ifconfig_xx keywords cannot be escaped p bin/126324 rc [patch] rc.d/tmp: Prevent mounting /tmp in second tim o conf/124747 rc [patch] savecore can't create dump from encrypted swap o conf/124248 rc [jail] [patch] add support for nice value for rc.d/jai o conf/123734 rc [patch] Chipset VIA CX700 requires extra initializatio o conf/123222 rc [patch] Add rtprio(1)/idprio(1) support to rc.subr(8). o conf/122968 rc [rc.d] /etc/rc.d/addswap: md swapfile multiplication a o conf/122477 rc [patch] /etc/rc.d/mdconfig and mdconfig2 are ignoring o conf/122170 rc [patch] [request] New feature: notify admin via page o o kern/121566 rc [nfs] [request] [patch] ethernet iface should be broug o conf/120431 rc [patch] devfs.rules are not initialized under certain o conf/120406 rc [devd] [patch] Handle newly attached pcm devices (eg. o conf/119874 rc [patch] "/etc/rc.d/pf reload" fails if there are macro o conf/119076 rc [patch] [rc.d] /etc/rc.d/netif tries to remove alias a o bin/118325 rc [patch] [request] new periodic script to test statuses o conf/118255 rc savecore never finding kernel core dumps (rcorder prob o conf/117935 rc [patch] ppp fails to start at boot because of missing o conf/113915 rc [patch] ndis wireless driver fails to associate when i o conf/109980 rc /etc/rc.d/netif restart doesn't destroy cloned_interfa o conf/109562 rc [rc.d] [patch] [request] Make rc.d/devfs usable from c o conf/108589 rc rtsol(8) fails due to default ipfw rules o conf/106009 rc [ppp] [patch] [request] Fix pppoed startup script to p o conf/105689 rc [ppp] [request] syslogd starts too late at boot o conf/105568 rc [patch] [request] Add more flexibility to rc.conf, to o conf/105145 rc [ppp] [patch] [request] add redial function to rc.d/pp o conf/104549 rc [patch] rc.d/nfsd needs special _find_processes functi o conf/102700 rc [geli] [patch] Add encrypted /tmp support to GELI/GBDE o conf/99721 rc [patch] /etc/rc.initdiskless problem copy dotfile in s o conf/99444 rc [patch] Enhancement: rc.subr could easily support star o conf/96343 rc [patch] rc.d order change to start inet6 before pf o conf/93815 rc [patch] Adds in the ability to save ipfw rules to rc.d o conf/92523 rc [patch] allow rc scripts to kill process after a timeo o conf/89870 rc [patch] [request] make netif verbose rc.conf toggle o conf/89061 rc [patch] IPv6 6to4 auto-configuration enhancement o conf/88913 rc [patch] wrapper support for rc.subr o conf/85819 rc [patch] script allowing multiuser mode in spite of fsc o kern/81006 rc ipnat not working with tunnel interfaces on startup o conf/77663 rc Suggestion: add /etc/rc.d/addnetswap after addcritremo o conf/73677 rc [patch] add support for powernow states to power_profi o conf/58939 rc [patch] dumb little hack for /etc/rc.firewall{,6} o conf/56934 rc [patch] rc.firewall rules for natd expect an interface o conf/45226 rc [patch] Fix for rc.network, ppp-user annoyance o conf/44170 rc [patch] Add ability to run multiple pppoed(8) on start 83 problems total. From owner-freebsd-rc@FreeBSD.ORG Tue Jul 20 22:34:37 2010 Return-Path: Delivered-To: rc@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 09C461065672 for ; Tue, 20 Jul 2010 22:34:37 +0000 (UTC) (envelope-from glarkin@FreeBSD.org) Received: from mail1.sourcehosting.net (113901-app1.sourcehosting.net [72.32.213.11]) by mx1.freebsd.org (Postfix) with ESMTP id DB6318FC08 for ; Tue, 20 Jul 2010 22:34:36 +0000 (UTC) Received: from 68-189-245-235.dhcp.oxfr.ma.charter.com ([68.189.245.235] helo=cube.entropy.prv) by mail1.sourcehosting.net with esmtp (Exim 4.69 (FreeBSD)) (envelope-from ) id 1ObKsC-000Bje-7U; Tue, 20 Jul 2010 18:01:17 -0400 Received: from [127.0.0.1] (fireball.entropy.prv [192.168.1.12]) by cube.entropy.prv (Postfix) with ESMTP id 102B842BBA55; Tue, 20 Jul 2010 18:01:12 -0400 (EDT) Message-ID: <4C461CA5.2040307@FreeBSD.org> Date: Tue, 20 Jul 2010 18:01:09 -0400 From: Greg Larkin Organization: The FreeBSD Project User-Agent: Thunderbird 2.0.0.24 (Windows/20100228) MIME-Version: 1.0 To: Ed Schouten References: <20100717105658.GV1742@hoeg.nl> In-Reply-To: <20100717105658.GV1742@hoeg.nl> X-Enigmail-Version: 0.96.0 OpenPGP: id=1C940290 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam-Score: -0.3 (/) Cc: ports@FreeBSD.org, rc@FreeBSD.org Subject: Re: General note on rc scripts and daemonizing X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: glarkin@FreeBSD.org List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Jul 2010 22:34:37 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Ed Schouten wrote: > Hello port maintainers, > > I think I'd better send an email about this to ports@, because I've seen > it in various places and it is getting a bit tiresome to mail all port > authors individually. > > I've seen various cases in the past where people write rc scripts that > do the following: > > command="/usr/local/bin/dog" > command_args="--bark > /dev/null 2>&1 &" > > So in this case `dog --bark' doesn't daemonize itself, so the & is > sufficient here, right? Well, it is not. :-) The point is that we simply > tell the kernel to redirect stdout/stderr and run it in the background. > It doesn't tell the kernel that the process should run in a separate > session (see getsid(2)/setsid(2)). > > This has various implications. The most important one I can think of, is > that the daemon can still do open("/dev/tty", ...) if it wants and spam > your TTY, even if the daemon is running as user `nobody'. This also > means that if you run the rc script from within a pseudo-terminal, it > can never actually destroy the pseudo-terminal for you, because maybe > the daemon is interested in using it. > > Below is the output of `pstat -t' on one of my systems, where I decided > to fire up MySQL: > > | LINE INQ CAN LIN LOW OUTQ USE LOW COL SESS PGID STATE > | ... > | pts/11 0 0 0 0 0 0 0 0 82711 0 G > > The kernel actually wants to clean up this pseudo-terminal (state = G), > but it is prevented from doing so. It will only clean it up by the time > MySQL is shut down. > > So how can this be solved? We already have a tool in base called > daemon(8). It is simply a wrapper around daemon(3) (which calls > setsid(2), which you can use to daemonize processes. So the next time > you write an rc script and need to daemonize something which cannot do > it by itself, please think of the kittens. ;-) > > [ CCing this to rc@. Maybe we should add some kind of built-in > functionality to call daemon(8)? ] > Hi all, Ed alerted me to this problem in the mail/nullmailer port some months back, and I fixed it with his assistance. A user recently opened a PR on another port I maintain (devel/viewvc), and I noticed that it had the same problem with its standalone server. This was a little harder to fix, since viewvc is a Python script. Anyway, here are some examples for daemonizing processes that don't already have support for doing it themselves: Daemonizing an executable without internal daemon support: http://www.freebsd.org/cgi/cvsweb.cgi/ports/mail/nullmailer/files/nullmailer.in?rev=1.3;content-type=text%2Fplain Daemonizing a Python script: http://www.freebsd.org/cgi/cvsweb.cgi/ports/devel/viewvc/files/viewvc.in?rev=1.4;content-type=text%2Fplain I would love to see direct support for these use cases in /etc/rc.subr, and am interested in working with someone to add it. - -Greg - -- Greg Larkin http://www.FreeBSD.org/ - The Power To Serve http://www.sourcehosting.net/ - Ready. Set. Code. http://twitter.com/sourcehosting/ - Follow me, follow you -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iD4DBQFMRhyl0sRouByUApARAtJGAJoCt2be6rCer1Ws2wozsHrOS07W/wCYj/Vf Wg2eRfLqb/dHa/VjnqxlPA== =hbwR -----END PGP SIGNATURE----- From owner-freebsd-rc@FreeBSD.ORG Tue Jul 20 22:38:47 2010 Return-Path: Delivered-To: rc@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5FBB21065678 for ; Tue, 20 Jul 2010 22:38:47 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from mail2.fluidhosting.com (mx21.fluidhosting.com [204.14.89.4]) by mx1.freebsd.org (Postfix) with ESMTP id 06D4C8FC13 for ; Tue, 20 Jul 2010 22:38:46 +0000 (UTC) Received: (qmail 2354 invoked by uid 399); 20 Jul 2010 22:38:45 -0000 Received: from localhost (HELO laptop.dougb.net) (dougb@dougbarton.us@127.0.0.1) by localhost with ESMTPAM; 20 Jul 2010 22:38:45 -0000 X-Originating-IP: 127.0.0.1 X-Sender: dougb@dougbarton.us Date: Tue, 20 Jul 2010 15:38:44 -0700 (PDT) From: Doug Barton To: Greg Larkin In-Reply-To: <4C461CA5.2040307@FreeBSD.org> Message-ID: References: <20100717105658.GV1742@hoeg.nl> <4C461CA5.2040307@FreeBSD.org> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) X-message-flag: Outlook -- Not just for spreading viruses anymore! OpenPGP: id=1A1ABC84 Organization: http://SupersetSolutions.com/ MIME-Version: 1.0 Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII Cc: ports@FreeBSD.org, Ed Schouten , rc@FreeBSD.org Subject: Re: General note on rc scripts and daemonizing X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Jul 2010 22:38:47 -0000 On Tue, 20 Jul 2010, Greg Larkin wrote: > Ed Schouten wrote: >> Hello port maintainers, >> >> I think I'd better send an email about this to ports@, because I've seen >> it in various places and it is getting a bit tiresome to mail all port >> authors individually. Unfortunately not all port maintainers follow this list, so you're not off the hook yet. :) I did a quick and dirty grep for this problem and it looks like it affects about 76 ports, so not an overwhelming number, but not a quick afternoon's work either. >> I've seen various cases in the past where people write rc scripts that >> do the following: >> >> command="/usr/local/bin/dog" >> command_args="--bark > /dev/null 2>&1 &" >> >> So in this case `dog --bark' doesn't daemonize itself, so the & is >> sufficient here, right? Well, it is not. :-) Thanks for your excellent analysis of this problem, it's very useful information. >> So how can this be solved? We already have a tool in base called >> daemon(8). It is simply a wrapper around daemon(3) (which calls >> setsid(2), which you can use to daemonize processes. So the next time >> you write an rc script and need to daemonize something which cannot do >> it by itself, please think of the kittens. ;-) >> >> [ CCing this to rc@. Maybe we should add some kind of built-in >> functionality to call daemon(8)? ] In theory, yes. Currently daemon(8) is located in /usr/sbin which could be problematic for people doing diskless, but in practice I don't know of any ports rc.d scripts that start so early that this would be a problem. If it turns out that it is, we can always move it to /sbin. > Anyway, here are some examples for daemonizing processes that don't > already have support for doing it themselves: > > Daemonizing an executable without internal daemon support: > http://www.freebsd.org/cgi/cvsweb.cgi/ports/mail/nullmailer/files/nullmailer.in?rev=1.3;content-type=text%2Fplain > > Daemonizing a Python script: > http://www.freebsd.org/cgi/cvsweb.cgi/ports/devel/viewvc/files/viewvc.in?rev=1.4;content-type=text%2Fplain > > I would love to see direct support for these use cases in /etc/rc.subr, > and am interested in working with someone to add it. Your first example looks right, I don't know enough about python to comment on the second. There is also http://www.freebsd.org/cgi/query-pr.cgi?pr=conf/90163 which has some insight into this. I previously closed that PR, but now it may be time to revisit this problem. I heartily encourage you to go forward if you're interested in patching rc.subr to take care of this. However, there will have to be a ramp-up period since even if you fix it today, you have about 3 years before you can guarantee that users on all supported versions of FreeBSD have the code in rc.subr (which is one of the unstated reasons that I closed the PR mentioned above). Here is my perspective on the project: 1. Document the issue in http://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/rc-scripts.html and give examples of how to do it properly. 2. Contact authors of existing ports that have this issue, and point them to the documentation. Offer help to fix it. 3. Take a page from pgolluci's book and file PRs with fixes for those who don't respond in a timely manner, then use the "maintainer timeout" facility to finish the fixes. 4. After 1., but perhaps in parallel with 2. and 3.; develop a patch for rc.subr to handle this, perhaps starting with the simple cases. The patch should include a signaling mechanism so that a port rc.d script can do something equivalent to: if [ $rc_subr_with_daemon_fix ]; then do it the easy way else do it the hard way fi 5. Once there is a new mechanism, repeat the steps in 1-3. :) 6. In 3-4 years, remove the crutches and mandate use of the new mechanism. One could also argue that documentation and education are the right answers, and that patching rc.subr is not necessary. Personally I'm sympathetic to that line of reasoning, but I'd never want to discourage someone from improving rc.subr. If you, or anyone are interested in pursuing any part of this then I'm happy to help review patches, make suggestions, etc. but I am not going to be able to own the project, I don't have the time. I would suggest that starting a new thread on -rc would be the right way to move forward. hth, Doug -- Improve the effectiveness of your Internet presence with a domain name makeover! http://SupersetSolutions.com/ Computers are useless. They can only give you answers. -- Pablo Picasso From owner-freebsd-rc@FreeBSD.ORG Tue Jul 20 23:16:10 2010 Return-Path: Delivered-To: rc@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0CA841065670; Tue, 20 Jul 2010 23:16:10 +0000 (UTC) (envelope-from glarkin@FreeBSD.org) Received: from mail1.sourcehosting.net (113901-app1.sourcehosting.net [72.32.213.11]) by mx1.freebsd.org (Postfix) with ESMTP id DA89C8FC14; Tue, 20 Jul 2010 23:16:09 +0000 (UTC) Received: from 68-189-245-235.dhcp.oxfr.ma.charter.com ([68.189.245.235] helo=cube.entropy.prv) by mail1.sourcehosting.net with esmtp (Exim 4.69 (FreeBSD)) (envelope-from ) id 1ObM2d-000CAk-1m; Tue, 20 Jul 2010 19:16:08 -0400 Received: from [127.0.0.1] (fireball.entropy.prv [192.168.1.12]) by cube.entropy.prv (Postfix) with ESMTP id 6D19442BC27E; Tue, 20 Jul 2010 19:16:03 -0400 (EDT) Message-ID: <4C462E31.4030801@FreeBSD.org> Date: Tue, 20 Jul 2010 19:16:01 -0400 From: Greg Larkin Organization: The FreeBSD Project User-Agent: Thunderbird 2.0.0.24 (Windows/20100228) MIME-Version: 1.0 To: Doug Barton References: <20100717105658.GV1742@hoeg.nl> <4C461CA5.2040307@FreeBSD.org> In-Reply-To: X-Enigmail-Version: 0.96.0 OpenPGP: id=1C940290 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam-Score: 0.1 (/) Cc: ports@FreeBSD.org, Ed Schouten , rc@FreeBSD.org Subject: Re: General note on rc scripts and daemonizing X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: glarkin@FreeBSD.org List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Jul 2010 23:16:10 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Doug Barton wrote: > On Tue, 20 Jul 2010, Greg Larkin wrote: [...] >> Anyway, here are some examples for daemonizing processes that don't >> already have support for doing it themselves: >> >> Daemonizing an executable without internal daemon support: >> http://www.freebsd.org/cgi/cvsweb.cgi/ports/mail/nullmailer/files/nullmailer.in?rev=1.3;content-type=text%2Fplain >> >> >> Daemonizing a Python script: >> http://www.freebsd.org/cgi/cvsweb.cgi/ports/devel/viewvc/files/viewvc.in?rev=1.4;content-type=text%2Fplain >> >> >> I would love to see direct support for these use cases in /etc/rc.subr, >> and am interested in working with someone to add it. > > Your first example looks right, I don't know enough about python to > comment on the second. There is also > http://www.freebsd.org/cgi/query-pr.cgi?pr=conf/90163 which has some > insight into this. I previously closed that PR, but now it may be time > to revisit this problem. > > I heartily encourage you to go forward if you're interested in patching > rc.subr to take care of this. However, there will have to be a ramp-up > period since even if you fix it today, you have about 3 years before you > can guarantee that users on all supported versions of FreeBSD have the > code in rc.subr (which is one of the unstated reasons that I closed the > PR mentioned above). > > Here is my perspective on the project: > 1. Document the issue in > http://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/rc-scripts.html > and give examples of how to do it properly. > 2. Contact authors of existing ports that have this issue, and point > them to the documentation. Offer help to fix it. > 3. Take a page from pgolluci's book and file PRs with fixes for those > who don't respond in a timely manner, then use the "maintainer timeout" > facility to finish the fixes. > 4. After 1., but perhaps in parallel with 2. and 3.; develop a patch for > rc.subr to handle this, perhaps starting with the simple cases. The > patch should include a signaling mechanism so that a port rc.d script > can do something equivalent to: > if [ $rc_subr_with_daemon_fix ]; then > do it the easy way > else > do it the hard way > fi > 5. Once there is a new mechanism, repeat the steps in 1-3. :) > 6. In 3-4 years, remove the crutches and mandate use of the new mechanism. > > One could also argue that documentation and education are the right > answers, and that patching rc.subr is not necessary. Personally I'm > sympathetic to that line of reasoning, but I'd never want to discourage > someone from improving rc.subr. > > If you, or anyone are interested in pursuing any part of this then I'm > happy to help review patches, make suggestions, etc. but I am not going > to be able to own the project, I don't have the time. I would suggest > that starting a new thread on -rc would be the right way to move forward. > > > hth, > > Doug > Hi Doug, Thank you for the useful background information and ideas about how to proceed forward. I'll put this task on my list (hah!) and see how much progress I can make. Cheers, Greg - -- Greg Larkin http://www.FreeBSD.org/ - The Power To Serve http://www.sourcehosting.net/ - Ready. Set. Code. http://twitter.com/sourcehosting/ - Follow me, follow you -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iD8DBQFMRi4x0sRouByUApARAlFzAKCE6mkF0zqxwIdR5vRYjCGpub0pFgCeNBl/ SFS3p4Mkl754eone1H8NmL4= =8kT2 -----END PGP SIGNATURE----- From owner-freebsd-rc@FreeBSD.ORG Tue Jul 20 23:19:03 2010 Return-Path: Delivered-To: rc@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C99CD1065674 for ; Tue, 20 Jul 2010 23:19:03 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from mail2.fluidhosting.com (mx21.fluidhosting.com [204.14.89.4]) by mx1.freebsd.org (Postfix) with ESMTP id 594418FC1C for ; Tue, 20 Jul 2010 23:19:02 +0000 (UTC) Received: (qmail 25759 invoked by uid 399); 20 Jul 2010 23:19:02 -0000 Received: from localhost (HELO laptop.dougb.net) (dougb@dougbarton.us@127.0.0.1) by localhost with ESMTPAM; 20 Jul 2010 23:19:02 -0000 X-Originating-IP: 127.0.0.1 X-Sender: dougb@dougbarton.us Date: Tue, 20 Jul 2010 16:18:58 -0700 (PDT) From: Doug Barton To: Greg Larkin In-Reply-To: <4C462E31.4030801@FreeBSD.org> Message-ID: References: <20100717105658.GV1742@hoeg.nl> <4C461CA5.2040307@FreeBSD.org> <4C462E31.4030801@FreeBSD.org> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) X-message-flag: Outlook -- Not just for spreading viruses anymore! OpenPGP: id=1A1ABC84 Organization: http://SupersetSolutions.com/ MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: ports@FreeBSD.org, Ed Schouten , rc@FreeBSD.org Subject: Re: General note on rc scripts and daemonizing X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Jul 2010 23:19:03 -0000 On Tue, 20 Jul 2010, Greg Larkin wrote: > Hi Doug, > > Thank you for the useful background information and ideas about how to > proceed forward. I'll put this task on my list (hah!) and see how much > progress I can make. Glad to help! :) -- Improve the effectiveness of your Internet presence with a domain name makeover! http://SupersetSolutions.com/ Computers are useless. They can only give you answers. -- Pablo Picasso From owner-freebsd-rc@FreeBSD.ORG Wed Jul 21 00:14:26 2010 Return-Path: Delivered-To: rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DC19B1065673; Wed, 21 Jul 2010 00:14:26 +0000 (UTC) (envelope-from jos@catnook.com) Received: from mail-gx0-f182.google.com (mail-gx0-f182.google.com [209.85.161.182]) by mx1.freebsd.org (Postfix) with ESMTP id 63B298FC1B; Wed, 21 Jul 2010 00:14:26 +0000 (UTC) Received: by gxk24 with SMTP id 24so4132007gxk.13 for ; Tue, 20 Jul 2010 17:14:25 -0700 (PDT) MIME-Version: 1.0 Received: by 10.151.93.11 with SMTP id v11mr1071087ybl.372.1279669582660; Tue, 20 Jul 2010 16:46:22 -0700 (PDT) Received: by 10.150.201.10 with HTTP; Tue, 20 Jul 2010 16:46:22 -0700 (PDT) Received: by 10.150.201.10 with HTTP; Tue, 20 Jul 2010 16:46:22 -0700 (PDT) In-Reply-To: References: <20100717105658.GV1742@hoeg.nl> <4C461CA5.2040307@FreeBSD.org> <4C462E31.4030801@FreeBSD.org> Date: Tue, 20 Jul 2010 16:46:22 -0700 Message-ID: From: Jos Backus To: Doug Barton Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: Greg Larkin , Ed Schouten , rc@freebsd.org, ports@freebsd.org Subject: Re: General note on rc scripts and daemonizing X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Jul 2010 00:14:27 -0000 Fwiw, I would much prefer FreeBSD ship with some sort of process supervisor a la daemontools. Jos From owner-freebsd-rc@FreeBSD.ORG Wed Jul 21 00:25:06 2010 Return-Path: Delivered-To: rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EE7B91065675 for ; Wed, 21 Jul 2010 00:25:06 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from mail2.fluidhosting.com (mx21.fluidhosting.com [204.14.89.4]) by mx1.freebsd.org (Postfix) with ESMTP id 38B288FC20 for ; Wed, 21 Jul 2010 00:25:05 +0000 (UTC) Received: (qmail 18712 invoked by uid 399); 21 Jul 2010 00:25:05 -0000 Received: from localhost (HELO lap.dougb.net) (dougb@dougbarton.us@127.0.0.1) by localhost with ESMTPAM; 21 Jul 2010 00:25:05 -0000 X-Originating-IP: 127.0.0.1 X-Sender: dougb@dougbarton.us Message-ID: <4C463E5F.2030308@FreeBSD.org> Date: Tue, 20 Jul 2010 17:25:03 -0700 From: Doug Barton Organization: http://SupersetSolutions.com/ User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.4) Gecko/20100608 Thunderbird/3.1 MIME-Version: 1.0 To: Jos Backus References: <20100717105658.GV1742@hoeg.nl> <4C461CA5.2040307@FreeBSD.org> <4C462E31.4030801@FreeBSD.org> In-Reply-To: X-Enigmail-Version: 1.1.1 OpenPGP: id=1A1ABC84 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Greg Larkin , Ed Schouten , rc@freebsd.org, ports@freebsd.org Subject: Re: General note on rc scripts and daemonizing X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Jul 2010 00:25:07 -0000 On 07/20/10 16:46, Jos Backus wrote: > Fwiw, I would much prefer FreeBSD ship with some sort of process supervisor > a la daemontools. That's an interesting idea, but until we have someone willing to actually do that work we need to deal with what we have. Doug -- Improve the effectiveness of your Internet presence with a domain name makeover! http://SupersetSolutions.com/ Computers are useless. They can only give you answers. -- Pablo Picasso From owner-freebsd-rc@FreeBSD.ORG Thu Jul 22 01:38:11 2010 Return-Path: Delivered-To: rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A98761065672; Thu, 22 Jul 2010 01:38:11 +0000 (UTC) (envelope-from trhodes@FreeBSD.org) Received: from hapkido.dreamhost.com (hapkido.dreamhost.com [66.33.216.122]) by mx1.freebsd.org (Postfix) with ESMTP id 86EE98FC08; Thu, 22 Jul 2010 01:38:11 +0000 (UTC) Received: from homiemail-a34.g.dreamhost.com (caiajhbdcagg.dreamhost.com [208.97.132.66]) by hapkido.dreamhost.com (Postfix) with ESMTP id 6CEC617C5D0; Wed, 21 Jul 2010 18:15:13 -0700 (PDT) Received: from homiemail-a34.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a34.g.dreamhost.com (Postfix) with ESMTP id C451D10060; Wed, 21 Jul 2010 18:15:10 -0700 (PDT) Received: from fbsdlab.fbsdsecure.org (c-76-21-169-24.hsd1.va.comcast.net [76.21.169.24]) (Authenticated sender: trhodes@fbsdsecure.org) by homiemail-a34.g.dreamhost.com (Postfix) with ESMTPA id EA2201005D; Wed, 21 Jul 2010 18:15:09 -0700 (PDT) Date: Wed, 21 Jul 2010 21:15:14 -0400 From: Tom Rhodes To: Doug Barton Message-Id: <20100721211514.0f28fff7.trhodes@FreeBSD.org> In-Reply-To: <4C463E5F.2030308@FreeBSD.org> References: <20100717105658.GV1742@hoeg.nl> <4C461CA5.2040307@FreeBSD.org> <4C462E31.4030801@FreeBSD.org> <4C463E5F.2030308@FreeBSD.org> X-Mailer: Sylpheed version 1.0.6 (GTK+ 1.2.10; i386-portbld-freebsd8.1) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: glarkin@freebsd.org, jos@catnook.com, rc@freebsd.org, ports@freebsd.org, ed@80386.nl Subject: Re: General note on rc scripts and daemonizing X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Jul 2010 01:38:11 -0000 Hey, On Tue, 20 Jul 2010 17:25:03 -0700 Doug Barton wrote: > On 07/20/10 16:46, Jos Backus wrote: > > Fwiw, I would much prefer FreeBSD ship with some sort of process supervisor > > a la daemontools. > > That's an interesting idea, but until we have someone willing to > actually do that work we need to deal with what we have. > > I wrote one. It's in the latest status report that, I gues, will be released soon. :) -- Tom Rhodes From owner-freebsd-rc@FreeBSD.ORG Fri Jul 23 08:29:25 2010 Return-Path: Delivered-To: rc@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BC9871065673 for ; Fri, 23 Jul 2010 08:29:25 +0000 (UTC) (envelope-from kamikaze@bsdforen.de) Received: from mail.bsdforen.de (bsdforen.de [212.204.60.79]) by mx1.freebsd.org (Postfix) with ESMTP id 7871B8FC20 for ; Fri, 23 Jul 2010 08:29:25 +0000 (UTC) Received: from mobileKamikaze.norad (vpn-cl-164-95.rz.uni-karlsruhe.de [141.3.164.95]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.bsdforen.de (Postfix) with ESMTP id 57F718A22B7; Fri, 23 Jul 2010 10:02:36 +0200 (CEST) Message-ID: <4C494C9B.1020109@bsdforen.de> Date: Fri, 23 Jul 2010 10:02:35 +0200 From: Dominic Fandrey User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-GB; rv:1.9.1.11) Gecko/20100722 Thunderbird/3.0.6 MIME-Version: 1.0 To: Ed Schouten References: <20100717105658.GV1742@hoeg.nl> In-Reply-To: <20100717105658.GV1742@hoeg.nl> X-Enigmail-Version: 1.0.1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: ports@FreeBSD.org, rc@FreeBSD.org Subject: Re: General note on rc scripts and daemonizing X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Jul 2010 08:29:25 -0000 On 17/07/2010 12:56, Ed Schouten wrote: > ... > > This has various implications. The most important one I can think of, is > that the daemon can still do open("/dev/tty", ...) if it wants and spam > your TTY, even if the daemon is running as user `nobody'. This also > means that if you run the rc script from within a pseudo-terminal, it > can never actually destroy the pseudo-terminal for you, because maybe > the daemon is interested in using it. What is not clear to me, in which way is that a problem? Regards -- A: Because it fouls the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet and in e-mail?