Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101655 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 5778 invoked from network); 22 Jan 2018 16:10:47 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Jan 2018 16:10:47 -0000 Authentication-Results: pb1.pair.com smtp.mail=david.proweb@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=david.proweb@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.175 as permitted sender) X-PHP-List-Original-Sender: david.proweb@gmail.com X-Host-Fingerprint: 209.85.223.175 mail-io0-f175.google.com Received: from [209.85.223.175] ([209.85.223.175:44684] helo=mail-io0-f175.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2E/28-28995-00D066A5 for ; Mon, 22 Jan 2018 11:10:43 -0500 Received: by mail-io0-f175.google.com with SMTP id z6so9925011iob.11 for ; Mon, 22 Jan 2018 08:10:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=46cNf//ibM6GJr+TPCcGilrsHI/vLo4g3wBF1yZktVU=; b=tONl4WHoAg0onKp7mz6UgitfLY26QyaKwNLK659QpVtUmGAUktlcNQjDcgGcak8tph o0iGLX1bNWBxe6hufQmYJHDaU5Nz18a2/yATwfhM1gDK18WdIzaX9aZXJL5KTRjfyIGS vxzFz7WWqTK2P96tmekoPS21o3noP7FJFNNyEBOxQlllRqmXFXDMIqcgvruabyTJpGue 7GF5lvXKmI4CWJkg31r0oszSxpgRgnA/KNdlpMXT67pB2kxfJJ5byELG9kKl9H6pqRiZ NMFKk4Bir+CRCGGynQE2BsGW+NCGJfORNjQ9rBd/BlXXnQqPlQwFBwjfIa/F9GOjCv45 NcRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=46cNf//ibM6GJr+TPCcGilrsHI/vLo4g3wBF1yZktVU=; b=fmLe/jfG9iaLKRf7GEcYJwWq2AHBQjjTS0GmyD1kCysC9LE9JdRdpfsiVwuMDzTe6N YdTKIguXCeqcPCt4yrrGZd8Drh4wXaNsFPgYVNGpmEMZh8klYQVLp0VDnZ4ovBWueRsO nMbDVNfptfVS9Y0F+QMp5pGsIlLLChYB9MUWGFCSw/bR6bOR0CfBE6gPh1u5oeh6cjNf 5W3cET/4SbO7UIDk4cyDIbkXMLa2FsKfw5NYqH1tvqvCVTTQoA5KabEMmiLzMhwlohjo Q4SOHVENrcG+IjvkacqWD7XGMHEqiPKuLnvD2j+84Cy84dn3hM3pQy+SDpw8cxsAM7Tj jbRw== X-Gm-Message-State: AKwxytcwOw1TThqUFnAG0dDyIo9hWS6hNu8lhAAGnYTe6/6RQHX91jgd z2obfKyh7AjCi1Tareej130Eb6B5VXbnqami55k= X-Google-Smtp-Source: AH8x224OVY8YU1bZ9qUcpz3nhjDEH5gNiYFNthx15k4KEfSu8BPcUHjbHD6EqINjbF/KVOcW3+4c65O4zJSKHKuEqfY= X-Received: by 10.107.46.13 with SMTP id i13mr8925989ioo.161.1516637437659; Mon, 22 Jan 2018 08:10:37 -0800 (PST) MIME-Version: 1.0 Received: by 10.2.48.211 with HTTP; Mon, 22 Jan 2018 08:10:17 -0800 (PST) In-Reply-To: <630ac0e1-692b-ae0b-54f3-94da6f9df7d9@cubiclesoft.com> References: <630ac0e1-692b-ae0b-54f3-94da6f9df7d9@cubiclesoft.com> Date: Mon, 22 Jan 2018 14:10:17 -0200 Message-ID: To: Thomas Hruska Cc: PHP Internals Content-Type: multipart/alternative; boundary="001a1134e22cb99d9405635fabb1" Subject: Re: [PHP-DEV] PCNTL compatibility to Windows? From: david.proweb@gmail.com (David Rodrigues) --001a1134e22cb99d9405635fabb1 Content-Type: text/plain; charset="UTF-8" Wow! Thanks for this very detailed anwser! I really could not understand everything because of my limitation about this topic, but I really could understand the reasons that it will not works fine and I agree that, for now, it is not a good idea (because of hackish way to implement it, mainly). Thank you! 2018-01-22 13:58 GMT-02:00 Thomas Hruska : > On 1/22/2018 5:16 AM, David Rodrigues wrote: > >> Hello. >> >> I know that PCNTL extension is not compatible with Windows, but I can't >> found the reason for that. >> >> I mean, I know that it is a feature that Unix system could provide in a >> better way (natively I guess). But "why" Windows could not emulates this >> features and have a PCNTL support too? Even if it had a lower performance, >> it still could be useful on testing environments. >> >> So the question is: there are some hard limitation to it be impossible or >> would it be kind of a "lack of interest"? >> >> Thanks! >> > > Windows is a completely different OS. > > > Windows does not have signals: > > https://stackoverflow.com/questions/3333276/signal-handling-on-windows > > That rules out all of PCNTL's signal handling support, which is 11 out of > the 22 functions that PCNTL has (I'm excluding aliases in that count). > Simply being unable to implement 50% of the functions is not a good start > to a successful port. > > > Windows does not have fork/exec. Although there are non-starter > "solutions": > > https://en.wikipedia.org/wiki/Fork%E2%80%93exec > > Windows starts and manages processes VERY differently from *NIX. Cygwin > apparently has a working fork/exec implementation for Windows, but Cygwin > is GPL. Any implementation would have to be clean-roomed for PHP and would > likely involve ugly things such as copying raw memory from one process > space to another and/or using undocumented Zw kernel calls, all of which > can change dramatically between OS releases. > > > Windows processes are referenced by HANDLE, not process ID. Referencing > by process ID might seem doable with OpenProcess(): > > https://msdn.microsoft.com/en-us/library/windows/desktop/ms6 > 84320(v=vs.85).aspx > > But even PROCESS_QUERY_LIMITED_INFORMATION access might be denied when > attempting to open the handle. Even for child processes. It happens when > a process changes its own DACLs specifically to block > OpenProcess()/OpenThread() calls. Although the approach can't readily > block SeDebugPrivilege, you don't ever want PHP core/userland running with > SeDebugPrivilege. > > A PHP implementation might work fine for direct children for most > use-cases where the HANDLEs are kept around, but grandchildren might not be > accessible. Also, there's already the "proc_..." series of functions for > handling child processes, which more correctly uses generic resource > handles instead of integers. > > > Windows does not know what a zombie process is. Unlike *NIX, Windows > doesn't have a rule that a child must have a parent and that the parent > must wait on each child to exit before the parent itself exits. Windows > processes can exit whenever they want and the kernel cleans up after the > process. > > > Windows does have a few process priorities: > > https://msdn.microsoft.com/en-us/library/windows/desktop/ms6 > 86219(v=vs.85).aspx > > However, you can do things such as completely freeze up Windows - > including the keyboard processing buffer and mouse cursor - with a process > priority of REALTIME_PRIORITY_CLASS and a "while (1)" loop where the > specified process will get *exclusive* scheduling by the kernel (i.e. a > reboot is the only option). It's a little-known security > vulnerability-waiting-to-happen bit of Windows API history. > > > I dunno. When all is said and done, pcntl_getpriority(), > pcntl_setpriority(), pcntl_get_last_error(), pcntl_strerror(), and maybe > pcntl_wait() and associated status functions are about the only functions > that can be somewhat cleanly implemented for Windows using Windows APIs > with minimal effort. pcntl_waitpid() might be able to be implemented with > some effort but possibly not work properly for pids less than 1 (with all > the usual waitpid() caveats). The signal handling are simply not doable. > Implementing fork/exec doesn't make a lot of sense - a lot of effort for > little gain. > > -- > Thomas Hruska > CubicleSoft President > > I've got great, time saving software that you will find useful. > > http://cubiclesoft.com/ > > And once you find my software useful: > > http://cubiclesoft.com/donate/ > -- David Rodrigues --001a1134e22cb99d9405635fabb1--