From owner-freebsd-stable@FreeBSD.ORG Thu Sep 30 07:28:20 2010 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AF84E1065674 for ; Thu, 30 Sep 2010 07:28:20 +0000 (UTC) (envelope-from jdc@koitsu.dyndns.org) Received: from qmta02.emeryville.ca.mail.comcast.net (qmta02.emeryville.ca.mail.comcast.net [76.96.30.24]) by mx1.freebsd.org (Postfix) with ESMTP id 95B118FC20 for ; Thu, 30 Sep 2010 07:28:20 +0000 (UTC) Received: from omta01.emeryville.ca.mail.comcast.net ([76.96.30.11]) by qmta02.emeryville.ca.mail.comcast.net with comcast id Cv4Q1f0030EPchoA2vULjP; Thu, 30 Sep 2010 07:28:20 +0000 Received: from koitsu.dyndns.org ([98.248.41.155]) by omta01.emeryville.ca.mail.comcast.net with comcast id CvUK1f0033LrwQ28MvUKVd; Thu, 30 Sep 2010 07:28:19 +0000 Received: by icarus.home.lan (Postfix, from userid 1000) id 0C82D9B418; Thu, 30 Sep 2010 00:28:19 -0700 (PDT) Date: Thu, 30 Sep 2010 00:28:19 -0700 From: Jeremy Chadwick To: Ed Schouten Message-ID: <20100930072819.GA10678@icarus.home.lan> References: <20100930065151.GA9634@icarus.home.lan> <20100930070333.GU87427@hoeg.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100930070333.GU87427@hoeg.nl> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: freebsd-stable@freebsd.org, ale@FreeBSD.org Subject: Re: mysqld_safe holding open a pty/tty on FreeBSD (7.x and 8.x) X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Sep 2010 07:28:20 -0000 On Thu, Sep 30, 2010 at 09:03:33AM +0200, Ed Schouten wrote: > Hi Jeremy, > > * Jeremy Chadwick wrote: > > 1) "mysqld_safe > /dev/null 2>&1 &" never released the tty > > 2) "nohup mysqld_safe > /dev/null 2>&1 &" did release the tty > > What happens if you run the following command? > > daemon -cf mysqld_safe Let's try it and find out. This is all being done from pts/2. icarus# ps -auxwww -U mysql | grep mysqld_safe mysql 9997 0.0 0.0 8228 1592 1- I 11:38PM 0:00.01 /bin/sh /usr/local/bin/mysqld_safe --defaults-extra-file=/storage/mysql/my.cnf --user=mysql --datadir=/storage/mysql --pid-file=/storage/mysql/icarus.home.lan.pid --skip-innodb icarus# /usr/local/etc/rc.d/mysql-server stop Stopping mysql. Waiting for PIDS: 10078. icarus# daemon -c -f -u mysql /usr/local/bin/mysqld_safe --defaults-extra-file=/storage/mysql/my.cnf --user=mysql --datadir=/storage/mysql --pid-file=/storage/mysql/icarus.home.lan.pid --skip-innodb icarus# ps -auxwww -U mysql USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND mysql 11036 0.0 0.0 8228 1600 ?? Is 12:21AM 0:00.01 /bin/sh /usr/local/bin/mysqld_safe --defaults-extra-file=/storage/mysql/my.cnf --user=mysql --datadir=/storage/mysql --pid-file=/storage/mysql/icarus.home.lan.pid --skip-innodb mysql 11116 0.0 0.3 35100 11032 ?? I 12:21AM 0:00.02 [mysqld] icarus# exit $ exit [another window, different tty] icarus# pstat -t | grep pts/2 icarus# Summary: looks good to me. > The point is that FreeBSD's pts(4) driver only deallocates TTYs when > it's really sure nothing uses it anymore. Even if there is not a single > file descriptor referring to the slave device, it has to wait until > there exist no processes which have the TTY as its controlling TTY. Ah I see. Well that would explain the difference between Linux and FreeBSD then -- it sounds like Linux has a one-off with regards to fds that point to /dev/null. > The `pstat -t' command is quite useful to figure out whether there is > still a session associated with the TTY. > > See the following thread: > > http://lists.freebsd.org/pipermail/freebsd-ports/2010-July/062417.html Ahhh, two people pointing me to the same thread, sweet. :-) I wasn't subscribed to -ports back in July, else I'd almost certainly have said something then. It's exactly as you stated in that thread -- the tty is in "G" state (waiting to be freed/process to exist). Please note the below output was obtained *before* attempting the "daemon -cf" stuff you recommended. icarus# pstat -t | grep pts/1 pts/1 0 0 0 0 0 0 0 0 9372 0 G Until rc(8) can be updated to support daemon(8) natively, the ~76 ports which Do The Wrong Thing(tm) should get updated to do it this way. Ones like mysqlXX-server should be placed high on the priority list given their popularity/importance. -- | Jeremy Chadwick jdc@parodius.com | | Parodius Networking http://www.parodius.com/ | | UNIX Systems Administrator Mountain View, CA, USA | | Making life hard for others since 1977. PGP: 4BD6C0CB |