Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:52096 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 79651 invoked from network); 30 Apr 2011 15:08:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Apr 2011 15:08:25 -0000 Authentication-Results: pb1.pair.com header.from=tyra3l@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: tyra3l@gmail.com X-Host-Fingerprint: 209.85.215.42 mail-ew0-f42.google.com Received: from [209.85.215.42] ([209.85.215.42:62991] helo=mail-ew0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 53/3B-10915-6E52CBD4 for ; Sat, 30 Apr 2011 11:08:23 -0400 Received: by ewy2 with SMTP id 2so1402946ewy.29 for ; Sat, 30 Apr 2011 08:08:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=+Sk5plvJR/kZlQKnewu5IvLcuAOHIXajSYoulJ07GgA=; b=O8/EpHhml/u0ul1rrg+j/qgppu41sO8OzmJAKubr5motxkeKTPHQhsu1wCH0AeAL4+ MHlO6g/YoedhxW8v3ZbbfmWTnzgEY393agOGexiH9jrGHjR7vsgVoBK9lKn0pueBBwqB Qa7EcYRGGsrJdRfMDyrDRlClDa1mtBx1IvFLQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=MewpQguvsx1v6iPZTxNg0L5IyFasWFGAcnao1PJEdwq9s7zRJOotPavtffmCPJLmjB j32pY8rD9S5MA4ji+U4xS5hURm4VEmVmYFtTUbgkFharhUR2mIYUvRoU80UhdX7Zf5aK TNn7jBCZ3HpldxSDGkXAe6p5g5mgrQdfuHGxU= MIME-Version: 1.0 Received: by 10.14.124.137 with SMTP id x9mr2545903eeh.231.1304176100023; Sat, 30 Apr 2011 08:08:20 -0700 (PDT) Sender: tyra3l@gmail.com Received: by 10.14.127.79 with HTTP; Sat, 30 Apr 2011 08:08:19 -0700 (PDT) In-Reply-To: <4DBC0679.6080400@thelounge.net> References: <4DBC0679.6080400@thelounge.net> Date: Sat, 30 Apr 2011 17:08:19 +0200 X-Google-Sender-Auth: lEJhOoxHsjdIo-mUPDSmV2MVNC4 Message-ID: To: Reindl Harald Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=e0cb4e6fff6f2a9cba04a2242929 Subject: Re: [PHP-DEV] adding low level file handling stuff From: info@tyrael.hu (Ferenc Kovacs) --e0cb4e6fff6f2a9cba04a2242929 Content-Type: text/plain; charset=UTF-8 On Sat, Apr 30, 2011 at 2:54 PM, Reindl Harald wrote: > > Am 30.04.2011 14:04, schrieb Ferenc Kovacs: > > Hi. > > > > recently I found a nice blogpost about how to properly daemonize a php > > daemon: > > > http://andytson.com/blog/2010/05/daemonising-a-php-cli-script-on-a-posix-system/ > > I've noticed in this article, that you can replace/redirect the > > STDIN/STDOUT/STDERR from inside of your script, you have to close them, > and > > open in the correct order. > > It works (at least on linux), because the opened files will have the > 1,2,3 > > FDs, because the OS assign the lowest available FD, which will happen to > be > > the required ones > > the cleaner way is to do this in a /etc/init.d/service-script > > in what way would a service script help this particular issue? or you mean like a wrapper script which sets the STDIN STDOUT STERR before launching the script? eg: nohup command < /dev/null > /dev/null 2>&1 & I find the command form much cleaner, but with the currently available tools one cannot use this, because there is no way to properly daemonize* (you can fork and posix_setsid but you cannot reopen the stdin, stdout and stderr) at least without doing a proc_open or exec * http://www.itp.uzh.ch/~dpotter/howto/daemonize > we are running a monitoring-service written in php wilh a while(1==1) > as linux-daemon since years and even config-changes are no problem with > an internal counter for reloading them every 10 while-runs > > sleep(1) is a good idea fpr each run to make sure the daemon eats not too > much ressources useless > > I agree (except while(true) is shorter, or even for(;;) but thats a little bit confusing at first :P), but this is irrevelant for this discussion, I didn't asked help on how to write a daemon app. Tyrael --e0cb4e6fff6f2a9cba04a2242929--