From owner-freebsd-stable@FreeBSD.ORG Thu Sep 30 06:51:54 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 69D4410656A3 for ; Thu, 30 Sep 2010 06:51:54 +0000 (UTC) (envelope-from jdc@koitsu.dyndns.org) Received: from qmta14.emeryville.ca.mail.comcast.net (qmta14.emeryville.ca.mail.comcast.net [76.96.27.212]) by mx1.freebsd.org (Postfix) with ESMTP id 51B238FC19 for ; Thu, 30 Sep 2010 06:51:53 +0000 (UTC) Received: from omta12.emeryville.ca.mail.comcast.net ([76.96.30.44]) by qmta14.emeryville.ca.mail.comcast.net with comcast id Cudx1f0040x6nqcAEurt1h; Thu, 30 Sep 2010 06:51:53 +0000 Received: from koitsu.dyndns.org ([98.248.41.155]) by omta12.emeryville.ca.mail.comcast.net with comcast id Curr1f00B3LrwQ28YurrFX; Thu, 30 Sep 2010 06:51:52 +0000 Received: by icarus.home.lan (Postfix, from userid 1000) id 7592A9B418; Wed, 29 Sep 2010 23:51:51 -0700 (PDT) Date: Wed, 29 Sep 2010 23:51:51 -0700 From: Jeremy Chadwick To: freebsd-stable@freebsd.org Message-ID: <20100930065151.GA9634@icarus.home.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Ed Schouten , ale@FreeBSD.org Subject: 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 06:51:54 -0000 Something interesting I've come across which happens on both RELENG_7 and RELENG_8 (indicating it's not a problem with the older tty code or the newer pty/pts code), and it's reproducible on Linux (sort of...). mysqld_safe appears to hold a pty/tty open even after the process has been backgrounded. I can understand how/why this might occur, just not in this particular case. I had a colleague test the situation on his Linux machine. He was able to confirm that: 1) "mysqld_safe > /dev/null 2>&1 &" never released the tty 2) "nohup mysqld_safe > /dev/null 2>&1 &" did release the tty With regards to test #1, looking in /proc/{pid}/fd showed that STDIN was being held open. I recommended he point STDIN to /dev/null as so: "mysqld_safe < /dev/null > /dev/null 2>&1 &" Which also solved the problem. On FreeBSD it's a different story. Below, mysql-server was started as root on pts/1. The open file descriptors all point to /dev/null, so I'm not sure why the pty/tty is being held open. icarus# ps -aux -U mysql USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND mysql 10078 0.2 0.3 35100 11032 1 S 11:38PM 0:00.02 [mysqld] mysql 9997 0.0 0.0 8228 1592 1 S 11:38PM 0:00.01 /bin/sh /usr/local/bin/mysqld_safe --defaults-extra-file=/storage/mys icarus# procstat -f 9997 PID COMM FD T V FLAGS REF OFFSET PRO NAME 9997 sh cwd v d -------- - - - /root 9997 sh root v d -------- - - - / 9997 sh 0 v c r------- 1 0 - /dev/null 9997 sh 1 v c -w------ 2 0 - /dev/null 9997 sh 2 v c -w------ 2 0 - /dev/null icarus# procstat -f 10078 PID COMM FD T V FLAGS REF OFFSET PRO NAME 10078 mysqld cwd v d -------- - - - /storage/mysql 10078 mysqld root v d -------- - - - / 10078 mysqld 0 v c r------- 1 0 - /dev/null 10078 mysqld 1 v r rwa----- 1 32048 - /storage/mysql/icarus.home.lan.err 10078 mysqld 2 v r rwa----- 1 32380 - /storage/mysql/icarus.home.lan.err At this point I log out of pts/1 and log back in to the machine (which sticks me on pts/2 as a result of the problem). Looking again, we see: icarus# ps -aux -U mysql USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND 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/mys mysql 10078 0.0 0.3 35100 11032 1- I 11:38PM 0:00.02 [mysqld] With absolutely no change in procstat output relevant to fds 0/1/2. Yet pts/1 still appears held open by something: icarus# ls -l /dev/pts total 0 crw--w---- 1 jdc tty 0, 116 Sep 29 23:44 0 crw-rw-rw- 1 root wheel 0, 115 Sep 29 23:41 1 crw--w---- 1 jdc tty 0, 117 Sep 29 23:44 2 fstat also shows no indication of anything using pts/1: icarus# fstat /dev/pts/1 USER CMD PID FD MOUNT INUM MODE SZ|DV R/W NAME icarus# fstat | grep pts/1 icarus# Ideas? -- | 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 |