From owner-freebsd-questions@freebsd.org Wed Jun 1 10:13:31 2016 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9DF49B585EC for ; Wed, 1 Jun 2016 10:13:31 +0000 (UTC) (envelope-from adam.lindberg@wooga.net) Received: from mail-wm0-x22f.google.com (mail-wm0-x22f.google.com [IPv6:2a00:1450:400c:c09::22f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 393D0104E for ; Wed, 1 Jun 2016 10:13:31 +0000 (UTC) (envelope-from adam.lindberg@wooga.net) Received: by mail-wm0-x22f.google.com with SMTP id z87so27403494wmh.1 for ; Wed, 01 Jun 2016 03:13:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wooga-net.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=1MDwVFfd6Bu7SmcyRJq5/mrUgZVADpQdaa2iJs/IGKw=; b=WzvUgc6nwJpVtu3LDIM51+1fBtnDVBO8+IMULV84AtK5eEe2Dde9BAvMg70+5iDlzh GYYf7XCO2XVZz/PN4bYsZeaHkjUxIZDJcpznOiDAyPK/unCZJXCxn9CsAuWPwbYqL0tK VVveTTXerkUkxegHJ8bBpjVobE5ptAd7jTk+PVVw9MBLqYIB34D/yKltKIVVWRxxfbIP atjFazmQt/wsE2Aeba2zL1565Z5gHd4CKG2MKG8qvReBLPYzWa4brIrQTZVcSsBGMcpj motsM12pe5HQeZ2aWqz2jbu+qU2ngvw/ugAx+ySzfo5VplmEAmrlzw4QmqIobf/QLUWj R7eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=1MDwVFfd6Bu7SmcyRJq5/mrUgZVADpQdaa2iJs/IGKw=; b=OEbg1OcOjo1oJTU550WfVHVlo0HvwxTKLGt6+n3cfhwdO6cfLREoNAKkBqBKwifDBV 2piw317AJlNk88p57qRnMFU8Hi2c36Oky/aAOz0t9oL7lWRhhiFO4yaeVjmfnFmZU1vK LIyXzqRljhlEeNGo2qu1N/EKbnAdJzIj/lQbYL+zYk83sQYoL6ZnHoYUTMLhSoNxXCUd +ii2RfcwsuWhQ2y4T9jRs4bB6YJYhpnUZ4RtNF9HnQRtrpRF4gb3Rp3B3LwOVzwlzx7E wProS0xj9+GKWXGbfIgoxSY2MKrZKZ6MKwfCdc58k3GGYyays+Y2n2SsJawYa5r0I3go +mtw== X-Gm-Message-State: ALyK8tKXOZH4tN+UlcVhTRMMr8tnfAfRCcodeQbNg0uLPkQZCOIB1OTOktsnBWvrU2bCFcwW X-Received: by 10.194.162.228 with SMTP id yd4mr2799739wjb.26.1464776009590; Wed, 01 Jun 2016 03:13:29 -0700 (PDT) Received: from [185.74.12.147] ([185.74.12.147]) by smtp.googlemail.com with ESMTPSA id v125sm21644891wmv.17.2016.06.01.03.13.28 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 01 Jun 2016 03:13:28 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Subject: Re: Pidfile generated by /usr/sbin/daemon not usable by rc.d script From: Adam Lindberg In-Reply-To: <20160526193917.C15883@sola.nimnet.asn.au> Date: Wed, 1 Jun 2016 12:13:27 +0200 Cc: RW , freebsd-questions@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: <6ECB89F6-4410-47D2-AA9B-1EA63B334CF0@wooga.net> References: <20160526193917.C15883@sola.nimnet.asn.au> To: Ian Smith X-Mailer: Apple Mail (2.3124) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Jun 2016 10:13:31 -0000 Sorry for the late reply. What we observed was that the `read _pid _junk < $_pidfile` line did = indeed work on the command line, after sourcing /etc/rc.subr. For some = strange reason it seems not to work from inside the service script for = us. Cheers, Adam -- Adam Lindberg | Backend Engineer Wooga GmbH | Saarbr=C3=BCcker Str. 38 | D-10405 Berlin Place of business: Berlin Registered at the local court Berlin-Charlottenburg, HRB 117846 B Managing Directors: Jens Begemann, Philipp M=C3=B6ser, Jan Miczaika > On 26 May 2016, at 12:10 , Ian Smith wrote: >=20 > In freebsd-questions Digest, Vol 625, Issue 4, Message: 19 > On Wed, 25 May 2016 20:26:56 +0100 RW = wrote: >> On Wed, 25 May 2016 17:12:36 +0200 >> Adam Lindberg wrote: >>=20 >>> Hi, >>>=20 >>> I don?t know what powerd is and how it factors into this. :-) >>=20 >> It's an example of a daemon that generates a pid file without a >> newline, and yet "stop" and "status" work. >>=20 >> It turns out that /etc/rc.d/powerd doesn't define pidfile, in which >> case rc.subr finds the pid from the output of ps. So it's not a >> counter-example and it does appear to be a bug that rc.subr can't = cope >> with a pid file without a newline. >>=20 >> You could use the same method, but using sed seems safer. >=20 > Just as another data point, from a 9.3 system (if relevant), where the=20= > majority of pidfiles have no trailing newline; no obvious consistency: >=20 > root@x200:~ # sh -c 'for i in /var/run/*.pid ; do echo $i; hd $i; = done' > /var/run/consolekit.pid > 00000000 39 31 31 0a |911.| > 00000004 > /var/run/cron.pid > 00000000 38 35 31 |851| > 00000003 > /var/run/devd.pid > 00000000 34 32 37 |427| > 00000003 > /var/run/dhclient.em0.pid > 00000000 33 34 38 |348| > 00000003 > /var/run/moused.pid > 00000000 37 31 39 |719| > 00000003 > /var/run/ntpd.pid > 00000000 36 39 32 |692| > 00000003 > /var/run/powerd.pid > 00000000 36 39 35 |695| > 00000003 > /var/run/sendmail.pid > 00000000 38 32 34 0a 2f 75 73 72 2f 73 62 69 6e 2f 73 65 = |824./usr/sbin/se| > 00000010 6e 64 6d 61 69 6c 20 2d 4c 20 73 6d 2d 6d 74 61 |ndmail -L = sm-mta| > 00000020 20 2d 62 64 20 2d 71 33 30 6d 20 2d 4f 44 61 65 | -bd = -q30m -ODae| > 00000030 6d 6f 6e 50 6f 72 74 4f 70 74 69 6f 6e 73 3d 41 = |monPortOptions=3DA| > 00000040 64 64 72 3d 6c 6f 63 61 6c 68 6f 73 74 0a = |ddr=3Dlocalhost.| > 0000004e > /var/run/sshd.pid > 00000000 38 30 31 0a |801.| > 00000004 > /var/run/syslog.pid > 00000000 35 39 30 |590| > 00000003 >=20 > check_pidfile in /etc/rc.subr (at 9.3 and in head I see) uses: > read _pid _junk < $_pidfile > which extracts pids ok with or without the newline. Don't suppose the=20= > behaviour of read in sh(1) might have changed in terms of separating=20= > words or in whitespace reckoning? Otherwise this is rather = mysterious. >=20 > cheers, Ian