Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99801 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 95215 invoked from network); 6 Jul 2017 18:02:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Jul 2017 18:02:00 -0000 Authentication-Results: pb1.pair.com header.from=me@kelunik.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=me@kelunik.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain kelunik.com from 81.169.146.219 cause and error) X-PHP-List-Original-Sender: me@kelunik.com X-Host-Fingerprint: 81.169.146.219 mo4-p00-ob.smtp.rzone.de Received: from [81.169.146.219] ([81.169.146.219:11848] helo=mo4-p00-ob.smtp.rzone.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 00/07-47109-61B7E595 for ; Thu, 06 Jul 2017 14:01:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1499364115; l=3972; s=domk; d=kelunik.com; h=Content-Type:Cc:To:Subject:Date:From:References:In-Reply-To: MIME-Version; bh=4bMBD1lcsE3FqNInLiZjPLNSRO3kiLZPLT8N8s/C9eM=; b=T9TxCA3NhjpEstbkSDfcLM/kf2lBCCc6jLyAy8NSn//PnO74mPuI01gCDRzUTbRN1O Kw0flkTd0WtrkGeT4FwxvORi1SPMJ5xUpT+zncKon36XogzJTECQlKwxknZFngIgymwR zSyPl+0jbF0wo/Rk/gW7j6mGlHlIyFXsZTcVc= X-RZG-AUTH: :IWkkfkWkbvHsXQGmRYmUo9mls2vWuiu+7SLDup6E67mzuoNHBqX73Q== X-RZG-CLASS-ID: mo00 Received: by mail-oi0-f43.google.com with SMTP id l130so8853200oib.1 for ; Thu, 06 Jul 2017 11:01:55 -0700 (PDT) X-Gm-Message-State: AIVw112wg7bEIdpTuMvw3jMfp7GXOkKTLUY3TalIZqjK3zdTucl4hGTW 2TMVmPXs5/yhuPqG/zQN3W5BeUkv0Q== X-Received: by 10.202.53.195 with SMTP id c186mr13596858oia.46.1499364114507; Thu, 06 Jul 2017 11:01:54 -0700 (PDT) MIME-Version: 1.0 Received: by 10.74.154.177 with HTTP; Thu, 6 Jul 2017 11:01:54 -0700 (PDT) In-Reply-To: References: Date: Thu, 6 Jul 2017 20:01:54 +0200 X-Gmail-Original-Message-ID: Message-ID: To: Sara Golemon , Bob Weinand Cc: Kalle Sommer Nielsen , Martijn van Duren , Internals Content-Type: multipart/alternative; boundary="001a113cf57c6f333d0553a9e9ac" Subject: Re: [PHP-DEV] Getting fd from stream From: me@kelunik.com (Niklas Keller) --001a113cf57c6f333d0553a9e9ac Content-Type: text/plain; charset="UTF-8" > > On Thu, Jul 6, 2017 at 10:53 AM, Kalle Sommer Nielsen > wrote: > > 2017-07-06 11:12 GMT+02:00 Martijn van Duren : > >> I have an (exotic) case where I need to be able to get the > >> filedescriptor from a previously opened stream (via stream_socket_pair) > >> to hand over to the child process, which needs to reexecute. > >> > > > "hand over to a child process" > Child as in pcntl_fork()? Or a subprocess via exec() et. al.? > > For the former, the variable should (I think) carry over. > For the latter, the stream number is going to be a meaningless value > to the subprocess. ((e.g. stdin (fd=0) for the parent is a different > source than stdin for the child, despite being the same number)). > > I'm not sure of your exact use case, but you might be able to use > proc_open to spawn the child and supply the socket in the descriptor > spec which will (I think, iirc) bind the internal socket to a new pipe > between the parent and child. Though it's possible you'll need to > maintain a proxy loop in the parent. > > 40% of the above is guesswork and conjecture, but maybe it'll spawn > the right question. There's a (I think undocumented) feature that allow transferring sockets to other processes with the socket extension. https://github.com/amphp/aerys/commit/40fae01e4f5f82570a0bc3cb8ebbf1fee36dbb0b Bob implemented that, so maybe he can help you. But what's your exact use case? Regards, Niklas --001a113cf57c6f333d0553a9e9ac--