-
-
21 Oct 2021 04:09:01 UTC
- Distribution: Proc-Background
- Module version: 1.30
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Repository
- Issues (4)
- Testers (1144 / 2 / 0)
- Kwalitee
Bus factor: 1- 70.24% Coverage
- License: perl_5
- Activity
24 month- Tools
- Download (31.64KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- unknown
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
Proc::Background::Win32 - Windows-specific implementation of process create/wait/kill
DESCRIPTION
This module does not have a public interface. Use Proc::Background.
NAME
Proc::Background::Win32 - Implementation of process management for Win32 systems
IMPLEMENTATION
Perl Fork Limitations
When Perl is built as a native Win32 application, the
fork
andexec
are a broken approximation of their Unix counterparts. Callingfork
creates a thread instead of a process, and there is no way to exit the thread without running Perl cleanup code, which could damage the parent in unpredictable ways, like closing file handles. CallingPOSIX::_exit
will kill both parent and child (the whole process), and even callingexec
in the child still runs global destruction. File handles are shared between parent and child, so any file handle redirection you perform in the forked child will affect the parent and vice versa.In short, never call
fork
orexec
on native Win32 Perl.Command Line
This module implements background processes using
Win32::Process
, which uses the Windows API's concepts ofCreateProcess
,TerminateProces
,WaitForSingleObject
,GetExitCode
, and so on.Windows CreateProcess expects an executable name and a command line; breaking the command line into an argument list is left to each individual application, most of which use the library function
CommandLineToArgvW
. This moduleWin32::ShellQuote
to parse and format Windows command lines.If you supply a single-string command line, and don't specify the executable with the
'exe'
option, it splits the command line and uses the first argument. Then it looks for that argument in thePATH
, searching again with a suffix of".exe"
if the original wasn't found.If you supply a command of multiple arguments, they are combined into a command line using
Win32::ShellQuote
. The first argument is used as the executable (unless you specified the'exe'
option), and gets the same path lookup.Initial File Handles
When no options are specified, the new process does not inherit any file handles of the current process. This differs from the Unix implementation, but I'm leaving it this way for back-compat. If you specify any of stdin, stdout, or stderr, this module delivers them to the new process by temporarily redirecting STDIN, STDOUT, and STDERR of the current process, which the child process then inherits. Any handle not specified will be inherited as-is. If you wish to redirect a handle to NUL, set the option to
undef
:stdin => undef, # stdin will read from NUL device stdout => $some_fh, # stdout will write to a file handle stderr => \*STDERR, # stderr will go to the same STDERR of the current process
AUTHORS
Blair Zajac <blair@orcaware.com>
Michael Conrad <mike@nrdvana.net>
VERSION
version 1.30
COPYRIGHT AND LICENSE
This software is copyright (c) 2021 by Michael Conrad, (C) 1998-2009 by Blair Zajac.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Module Install Instructions
To install Proc::Background, copy and paste the appropriate command in to your terminal.
cpanm Proc::Background
perl -MCPAN -e shell install Proc::Background
For more information on module installation, please visit the detailed CPAN module installation guide.