Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99800 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 86973 invoked from network); 6 Jul 2017 15:20:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Jul 2017 15:20:29 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@golemon.com; spf=softfail; sender-id=softfail Authentication-Results: pb1.pair.com header.from=php@golemon.com; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain golemon.com does not designate 209.85.128.171 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 209.85.128.171 mail-wr0-f171.google.com Received: from [209.85.128.171] ([209.85.128.171:33872] helo=mail-wr0-f171.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C3/36-47109-C355E595 for ; Thu, 06 Jul 2017 11:20:29 -0400 Received: by mail-wr0-f171.google.com with SMTP id 77so7285015wrb.1 for ; Thu, 06 Jul 2017 08:20:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golemon-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=iyfgYZ4LwcrYdHmTp3uZo4VvvHjU3v1mG99/0CNxPSU=; b=nWSK3ij8uGW23jBT9bzF3rPb9T8fG9SjfuV4NQrd0ViLQVpqcKLd2EKEMNCImyxQQQ uXRLHJ8/CN2LfW09eFMyyNguiFmHe45lXnmjoA0XMdTzbUvSAZwMxYKDW6Z1VqEkqydb N96ETZK3a3S1pXm4NxytO7buxna4U9zs5WiudKhBMGEcWFh6SKtZaBOvcEzL+sGkVOfn p7l77A8L5BmTsoYkoSgQBdz98loN8ougT6xN5hJWjZEOc3M/Jdl/6ql8yIvqsu7DIu/m 2yl1LZ38aXOrNdroTTqUCx9omWUD/KcjST6+G4TlHsMQsENTc5p3gyp1Nt4QVsOvyZzW bWGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=iyfgYZ4LwcrYdHmTp3uZo4VvvHjU3v1mG99/0CNxPSU=; b=N1TngCWjccq6CvDnFSMoTlIl14/URXzLve594upe8/QvxKbANYB5Fayj2EjSHAjJ8X 6tHHDB8uqw2JUshCHoBiTDWC7a4yt5i8w8DQ1UUHv52UkWSbUQBdpDHCmEqMIB4OAF3w Rn4gpgr3zXRKM4bYNDEHz09sGF/OTrjud535AmwNlVsYCJeHUkbV5Ttoz2tMnID3fWAy oZYbZ65BacWWQWdbSIIC4Snn2Qb80loi8QJcSjBY3wRWQUXlI8XcgWXwWsSQdsgstGC5 mg5CSij/RyC1sNwu9NMZ9CzxykBFknZr/lyV9dUY+ZuO3JA3OzA8a6h8O3lM77Zgx3wg rMKw== X-Gm-Message-State: AIVw112sy6F+wDPqhduyuA6ReiS9D5e/eY30pJMHi8YiQEVFtJqaSY6/ hgqst8ZYPgsM1ZBC9x08bDPjA8roK6NS X-Received: by 10.28.216.204 with SMTP id p195mr15628523wmg.50.1499354425650; Thu, 06 Jul 2017 08:20:25 -0700 (PDT) MIME-Version: 1.0 Sender: php@golemon.com Received: by 10.223.169.139 with HTTP; Thu, 6 Jul 2017 08:20:25 -0700 (PDT) X-Originating-IP: [206.252.215.26] In-Reply-To: References: Date: Thu, 6 Jul 2017 11:20:25 -0400 X-Google-Sender-Auth: b3Fn7XcNsdGRZNP2UIFcaZTK_2Q Message-ID: To: Kalle Sommer Nielsen Cc: Martijn van Duren , Internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] Getting fd from stream From: pollita@php.net (Sara Golemon) 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. -Sara