From owner-freebsd-questions@freebsd.org Fri Jun 3 08:18:57 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 BC91BB68B05 for ; Fri, 3 Jun 2016 08:18:57 +0000 (UTC) (envelope-from adam.lindberg@wooga.net) Received: from mail-wm0-x230.google.com (mail-wm0-x230.google.com [IPv6:2a00:1450:400c:c09::230]) (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 5BC08139E for ; Fri, 3 Jun 2016 08:18:57 +0000 (UTC) (envelope-from adam.lindberg@wooga.net) Received: by mail-wm0-x230.google.com with SMTP id a20so96159736wma.1 for ; Fri, 03 Jun 2016 01:18:57 -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=FrMAbe7VfKN5Fn+3Xp38Vq1bYipiMFAqUVFpUSV/llE=; b=zZYcc77gDXSNrKor9E9nmQLwOYnh6N7CZlUEBs/DcL90APyviGU6Om6XIvnaQ858IL gyoDzohzcu4Wyr8gpiC8t2qf/kRwnL/aTzHZaZ9LnJlkwxdkpZ6/FaoIFVzGtKG2dtr4 MDWCj6i8r6TPhlafBlkamXln//Q2gxn7m859PJJixqOv4+UzB3Vj40FM8PPAidJ3BJe7 5XJrtUb0nWJ5hbHhdf5qQ4h4EmI/uhwUHQG30tFkGzgOIpmm4wypD31nbnTSysgdvaio bJEUHwpQhytLnsvRzKoPOtcn9o18ogqCNNY23Vx8fLZ/CLzHGLgxkDQTYEG0vDcOLSu9 vX4w== 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=FrMAbe7VfKN5Fn+3Xp38Vq1bYipiMFAqUVFpUSV/llE=; b=mmons+k/iQVPDsCcfURHpM/TiDUYdR+XZ338WnfxWHFX3c6CxYGKYHv/hHnY8cgQQe 0EwPfddTgWUtf48nv349GwazJFgPU3DIp0NryeavDUkcUB8MAazyzATIwQVVRKm6r7eY XHDoK7KUlcg9vH73PrHJCZFMs5wRUHDWPSWTmQKkoSG6uamgeA2ZLF24T/Vz3e1eBjtv WARh0rX3d4Con8JHy/kUW4YhGiq3pgm8SrD9wAZpX+DOaXePZEls3ZnVqWPvZVZrF1wu JsbbeBc1nIM5FVOg7G8QgWGUdOowQ3SU5RGOhlN2N5w1d1r9us8Kxl/7YPGKPEvwmrST wE2g== X-Gm-Message-State: ALyK8tKTuFQD0aSJX5QFA8mYnipFTqWkYhYvng63J3Br1ppT8nFwRTUPfxXNs8hIkBrDgoEV X-Received: by 10.28.139.208 with SMTP id n199mr2662917wmd.68.1464941935534; Fri, 03 Jun 2016 01:18:55 -0700 (PDT) Received: from [10.29.11.28] ([178.162.209.132]) by smtp.googlemail.com with ESMTPSA id ju6sm4461692wjb.14.2016.06.03.01.18.54 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 03 Jun 2016 01:18:54 -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: <20160602230511.W15883@sola.nimnet.asn.au> Date: Fri, 3 Jun 2016 10:18:53 +0200 Cc: RW , freebsd-questions@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: <5C74A843-C2EB-424B-9254-0CD68A07E480@wooga.net> References: <20160602230511.W15883@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: Fri, 03 Jun 2016 08:18:57 -0000 We are using FreeBSD 10.1 STABLE. We are trying to demonize an Erlang = program. Erlang itself has support for detaching but cannot write = pidfiles. That=E2=80=99s why we=E2=80=99re trying to use daemon to wrap = it. My experience is also that read works in all cases without a newline, = except from inside the rc script. That I cannot explain. 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 02 Jun 2016, at 15:56 , Ian Smith wrote: >=20 > In freebsd-questions Digest, Vol 626, Issue 4, Message: 3 > On Wed, 1 Jun 2016 15:08:19 +0100 RW = wrote: >> On Wed, 1 Jun 2016 22:58:28 +1000 (EST) >> Ian Smith wrote: > [..] >>> Also, none of the others (here) need daemon(8) to run, in background >>> or otherwise .. are you sure that you require its functionality for >>> 'foo'? >>=20 >> Most daemons were written as such. daemon(8) is there for those that >> weren't or were written in a scripting language that doesn't support >> the double fork.=20 >=20 > Ah right, fair enough and thanks. >=20 >>> For one thing, it seems that daemon keeps the -p pidfile locked >>> during execution of the process; might that affect service status, >>> stop, etc? >>=20 >> I think the problem is pretty straightforward. If you run this >>=20 >> read _pid _junk < $_pidfile >>=20 >> and $_pidfile doesn't end in a newline, read will wait for one, just = as >> it would if you typed in a line and didn't hit return. >=20 > But it doesn't wait on 9.3 stable of last October at least with this=20= > small set of pidfiles, some with & some without trailing newline, = thus: >=20 > % cat ~/bin/pidtest.sh > #!/bin/sh > # 2/6/16 re RW's msg in questions@ > for _pidfile in /var/run/*.pid; do > echo $_pidfile > hd $_pidfile | head -1 > read _pid _junk < $_pidfile > echo "_pid: '$_pid' _junk: '$_junk'" > done > echo done >=20 > root@x200:~ # pidtest.sh > /var/run/consolekit.pid > 00000000 39 31 31 0a |911.| > _pid: '911' _junk: '' > /var/run/cron.pid > 00000000 38 35 31 |851| > _pid: '851' _junk: '' > /var/run/devd.pid > 00000000 34 32 37 |427| > _pid: '427' _junk: '' > /var/run/dhclient.em0.pid > 00000000 33 34 38 |348| > _pid: '348' _junk: '' > /var/run/moused.pid > 00000000 37 31 39 |719| > _pid: '719' _junk: '' > /var/run/ntpd.pid > 00000000 36 39 32 |692| > _pid: '692' _junk: '' > /var/run/powerd.pid > 00000000 36 39 35 |695| > _pid: '695' _junk: '' > /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| > _pid: '824' _junk: '' > /var/run/sshd.pid > 00000000 38 30 31 0a |801.| > _pid: '801' _junk: '' > /var/run/syslog.pid > 00000000 35 39 30 |590| > _pid: '590' _junk: '' > done >=20 > No ptoblem interactively either; one of each (that non-root can read): >=20 > $ read _pid _junk < /var/run/ntpd.pid > $ echo $_pid > 692 > $ echo $_junk >=20 > $ read _pid _junk < /var/run/sshd.pid > $ echo $_pid > 801 > $ echo $_junk >=20 > So maybe this issue is something new(er) in FreeBSD somewhere? >=20 > cheers, Ian (please cc me, digests can take a day) > _______________________________________________ > freebsd-questions@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to = "freebsd-questions-unsubscribe@freebsd.org"