Re: untethered child process

"Francisco Zarabozo" <[email protected]> Tue, 2 Aug 2016 16:28:32 -0500
Newsgroups gmane.comp.lang.perl.active-perl
Message-ID <[email protected]>
Éste es un mensaje de varias partes en formato MIME.
--===============1775399951==
Content-Type: multipart/alternative;
	boundary="----=_NextPart_000_0843_01D1ECDA.E8BD49C0"

Éste es un mensaje de varias partes en formato MIME.
------=_NextPart_000_0843_01D1ECDA.E8BD49C0
Content-Type: text/plain;
	charset="utf-8"
Content-Transfer-Encoding: quoted-printable

Hello John,

I=E2=80=99m going to share an undocumented secret with you. :-)

*This works on Windows only*

If you pass the number 1 as the first argument to the system function, =
then Perl executes it in a detached mode and lets you continue without =
waiting for it to return. This is an example:

########################

use strict;
use warnings;

# This will be an aditional perl process floating around for 60 seconds:
my $command =3D qq[perl -e "sleep 60"];

# The following call will execute it without waiting for it to return:
system 1, $command;

print "Ok, we're out of here!\n";

########################

If you run that code, you will get to the last print statement =
immediatly, but you willl be able to see the perl.exe process running in =
the task manager for 60 seconds before it ends. You can change what I =
put in the $command variable for whatever you are trying to execute.

HTH

Francisco Zarabozo



From: John DePasquale=20
Sent: Tuesday, August 02, 2016 11:52 AM
To: [email protected]=20
Subject: untethered child process

Hi all,

Is it truly possible to spawn a child process in perl on windows so that =
the parent process does NOT wait for the child process to finish before =
the parent continues its own processing? I=E2=80=99ve tried to =
accomplish this over the last couple of days using exec, system, =
wind32::process, proc::background, fork, and more, on windows server =
2008 using perl 5.22.1. For each of these statements I=E2=80=99m able to =
spawn a child process that runs a .bat file successfully, but in each =
case the parent waits for the .bat file to finish processing ( it takes =
about 40 seconds ) before the parent proceeds. I=E2=80=99m beginning to =
think that this is not really possible on windows. I have found dozens =
of sites that detail usage of each of these statements and I=E2=80=99ve =
tried them all. I can get all of them to launch and complete a child =
process but I can=E2=80=99t get the parent to NOT wait for completion.

Any guidance is very gratefully appreciated. Thank you.

-          john

=20

John DePasquale

Chief Executive Officer

Paradigm Consulting

=E2=80=9CProudly presenting the Vinopedia System=E2=80=9D

www.vinopedia.us

49 Dalby Street

Newton, MA  02458

Mobile: 617-610-2424

Fax: 617-600-7326


-------------------------------------------------------------------------=
-------

=20



-------------------------------------------------------------------------=
-------
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
------=_NextPart_000_0843_01D1ECDA.E8BD49C0
Content-Type: text/html;
	charset="utf-8"
Content-Transfer-Encoding: quoted-printable

<HTML xmlns=3D"http://www.w3.org/TR/REC-html40" xmlns:v =3D=20
"urn:schemas-microsoft-com:vml" xmlns:o =3D=20
"urn:schemas-microsoft-com:office:office" xmlns:w =3D=20
"urn:schemas-microsoft-com:office:word" xmlns:m =3D=20
"http://schemas.microsoft.com/office/2004/12/omml"><HEAD>
<META content=3D"text/html; charset=3Dus-ascii" =
http-equiv=3DContent-Type>
<META name=3DGenerator content=3D"Microsoft Word 14 (filtered medium)">
<STYLE>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</STYLE>

<STYLE><!--
/* Font Definitions */
@font-face
	{font-family:Wingdings;
	panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
	{font-family:Verdana;
	panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:purple;
	text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
	{mso-style-priority:34;
	margin-top:0in;
	margin-right:0in;
	margin-bottom:0in;
	margin-left:.5in;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";}
span.EmailStyle17
	{mso-style-type:personal-compose;
	font-family:"Calibri","sans-serif";
	color:windowtext;}
.MsoChpDefault
	{mso-style-type:export-only;
	font-family:"Calibri","sans-serif";}
@page WordSection1
	{size:8.5in 11.0in;
	margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
	{page:WordSection1;}
/* List Definitions */
@list l0
	{mso-list-id:1690371659;
	mso-list-type:hybrid;
	mso-list-template-ids:-1078962674 1710535832 67698691 67698693 67698689 =
67698691 67698693 67698689 67698691 67698693;}
@list l0:level1
	{mso-level-start-at:0;
	mso-level-number-format:bullet;
	mso-level-text:-;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;
	font-family:"Calibri","sans-serif";
	mso-fareast-font-family:Calibri;
	mso-bidi-font-family:"Times New Roman";}
@list l0:level2
	{mso-level-number-format:bullet;
	mso-level-text:o;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;
	font-family:"Courier New";}
@list l0:level3
	{mso-level-number-format:bullet;
	mso-level-text:\F0A7;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;
	font-family:Wingdings;}
@list l0:level4
	{mso-level-number-format:bullet;
	mso-level-text:\F0B7;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;
	font-family:Symbol;}
@list l0:level5
	{mso-level-number-format:bullet;
	mso-level-text:o;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;
	font-family:"Courier New";}
@list l0:level6
	{mso-level-number-format:bullet;
	mso-level-text:\F0A7;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;
	font-family:Wingdings;}
@list l0:level7
	{mso-level-number-format:bullet;
	mso-level-text:\F0B7;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;
	font-family:Symbol;}
@list l0:level8
	{mso-level-number-format:bullet;
	mso-level-text:o;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;
	font-family:"Courier New";}
@list l0:level9
	{mso-level-number-format:bullet;
	mso-level-text:\F0A7;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;
	font-family:Wingdings;}
ol
	{margin-bottom:0in;}
ul
	{margin-bottom:0in;}
--></STYLE>
</HEAD>
<BODY lang=3DEN-US dir=3Dltr link=3Dblue vLink=3Dpurple>
<DIV dir=3Dltr>
<DIV style=3D"FONT-SIZE: 12pt; FONT-FAMILY: 'Calibri'; COLOR: #000000">
<DIV>Hello John,</DIV>
<DIV>&nbsp;</DIV>
<DIV>I=E2=80=99m going to share an undocumented secret with you. =
:-)</DIV>
<DIV>&nbsp;</DIV>
<DIV><STRONG>*This works on Windows only*</STRONG></DIV>
<DIV>&nbsp;</DIV>
<DIV>If you pass the number 1 as the first argument to the <FONT=20
face=3D"Courier New"><STRONG>system</STRONG></FONT> function, then Perl =
executes=20
it in a detached mode and lets you continue without waiting for it to =
return.=20
This is an example:</DIV>
<DIV>&nbsp;</DIV>
<DIV>########################</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT color=3D#0000ff face=3D"Courier New">use strict;</FONT></DIV>
<DIV><FONT color=3D#0000ff face=3D"Courier New">use =
warnings;</FONT></DIV>
<DIV><FONT color=3D#0000ff face=3D"Courier New"></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#a5a5a5 face=3D"Courier New"># This will be an =
aditional perl=20
process floating around for 60 seconds:</FONT></DIV>
<DIV><FONT color=3D#0000ff face=3D"Courier New">my $command =3D qq[perl =
-e "sleep=20
60"];</FONT></DIV>
<DIV><FONT face=3D"Courier New"></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#a5a5a5 face=3D"Courier New"># The following call =
will execute it=20
without waiting for it to return:</FONT></DIV>
<DIV><FONT color=3D#0000ff face=3D"Courier New">system 1, =
$command;</FONT></DIV>
<DIV><FONT color=3D#0000ff face=3D"Courier New"></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#0000ff face=3D"Courier New">print "Ok, we're out of=20
here!\n";</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>########################</DIV>
<DIV>&nbsp;</DIV>
<DIV>If you run that code, you will get to the last print statement =
immediatly,=20
but you willl be able to see the perl.exe process running in the task =
manager=20
for 60 seconds before it ends. You can change what I put in the $command =

variable for whatever you are trying to execute.</DIV>
<DIV>&nbsp;</DIV>
<DIV>HTH</DIV>
<DIV>&nbsp;</DIV>
<DIV>Francisco Zarabozo</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV=20
style=3D'FONT-SIZE: small; TEXT-DECORATION: none; FONT-FAMILY: =
"Calibri"; FONT-WEIGHT: normal; COLOR: #000000; FONT-STYLE: normal; =
DISPLAY: inline'>
<DIV style=3D"FONT: 10pt tahoma">
<DIV>&nbsp;</DIV>
<DIV style=3D"BACKGROUND: #f5f5f5">
<DIV style=3D"font-color: black"><B>From:</B> <A =
[email protected]=20
href=3D"mailto:[email protected]">John DePasquale</A> </DIV>
<DIV><B>Sent:</B> Tuesday, August 02, 2016 11:52 AM</DIV>
<DIV><B>To:</B> <A [email protected]=20
href=3D"mailto:[email protected]">[email protected]=
ctiveState.com</A>=20
</DIV>
<DIV><B>Subject:</B> untethered child process</DIV></DIV></DIV>
<DIV>&nbsp;</DIV></DIV>
<DIV=20
style=3D'FONT-SIZE: small; TEXT-DECORATION: none; FONT-FAMILY: =
"Calibri"; FONT-WEIGHT: normal; COLOR: #000000; FONT-STYLE: normal; =
DISPLAY: inline'>
<DIV class=3DWordSection1>
<P class=3DMsoNormal>Hi all,<o:p></o:p></P>
<P class=3DMsoNormal>Is it truly possible to spawn a child process in =
perl on=20
windows so that the parent process does NOT wait for the child process =
to finish=20
before the parent continues its own processing? I=E2=80=99ve tried to =
accomplish this=20
over the last couple of days using exec, system, wind32::process,=20
proc::background, fork, and more, on windows server 2008 using perl =
5.22.1. For=20
each of these statements I=E2=80=99m able to spawn a child process that =
runs a .bat file=20
successfully, but in each case the parent waits for the .bat file to =
finish=20
processing ( it takes about 40 seconds ) before the parent proceeds. =
I=E2=80=99m=20
beginning to think that this is not really possible on windows. I have =
found=20
dozens of sites that detail usage of each of these statements and =
I=E2=80=99ve tried=20
them all. I can get all of them to launch and complete a child process =
but I=20
can=E2=80=99t get the parent to NOT wait for completion.<o:p></o:p></P>
<P class=3DMsoNormal>Any guidance is very gratefully appreciated. Thank=20
you.<o:p></o:p></P>
<P class=3DMsoListParagraph=20
style=3D"TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"><SPAN=20
style=3D"mso-list: ignore">-<SPAN=20
style=3D'FONT: 7pt "Times New =
Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
</SPAN></SPAN>john<o:p></o:p></P>
<P class=3DMsoNormal><o:p></o:p>&nbsp;</P>
<P class=3DMsoNormal><SPAN style=3D"COLOR: #1f497d">John=20
DePasquale<o:p></o:p></SPAN></P>
<P class=3DMsoNormal><SPAN style=3D"COLOR: #1f497d">Chief Executive=20
Officer<o:p></o:p></SPAN></P>
<P class=3DMsoNormal><SPAN style=3D"COLOR: #1f497d">Paradigm=20
Consulting<o:p></o:p></SPAN></P>
<P class=3DMsoNormal><I><SPAN style=3D"COLOR: #1f497d">=E2=80=9CProudly =
presenting the=20
Vinopedia System=E2=80=9D<o:p></o:p></SPAN></I></P>
<P class=3DMsoNormal><A href=3D"http://www.vinopedia.us/"><SPAN=20
style=3D"COLOR: blue">www.vinopedia.us</SPAN></A><o:p></o:p></P>
<P class=3DMsoNormal><SPAN style=3D"COLOR: #1f497d">49 Dalby=20
Street<o:p></o:p></SPAN></P>
<P class=3DMsoNormal><SPAN style=3D"COLOR: #1f497d">Newton, MA&nbsp;=20
02458<o:p></o:p></SPAN></P>
<P class=3DMsoNormal><SPAN style=3D"COLOR: #1f497d">Mobile:=20
617-610-2424<o:p></o:p></SPAN></P>
<P class=3DMsoNormal><SPAN style=3D"COLOR: #1f497d">Fax: =
617-600-7326</SPAN><SPAN=20
style=3D'FONT-FAMILY: "Verdana","sans-serif"; COLOR: =
#1f497d'><o:p></o:p></SPAN></P>
<DIV class=3DMsoNormal style=3D"TEXT-ALIGN: center" align=3Dcenter><SPAN =

style=3D'FONT-FAMILY: "Verdana","sans-serif"; COLOR: #1f497d'>
<HR align=3Dcenter SIZE=3D2 width=3D"100%">
</SPAN></DIV>
<P class=3DMsoNormal><o:p></o:p>&nbsp;</P></DIV>
<P>
<HR>
_______________________________________________<BR>ActivePerl mailing=20
list<BR>[email protected]<BR>To unsubscribe:=20
http://listserv.ActiveState.com/mailman/mysubs</DIV></DIV></DIV></BODY></=
HTML>

------=_NextPart_000_0843_01D1ECDA.E8BD49C0--


--===============1775399951==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============1775399951==--