Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Emulating system('COMMAND &') on Windows without using fork()

Reply
Thread Tools

Emulating system('COMMAND &') on Windows without using fork()

 
 
Jacob JKW
Guest
Posts: n/a
 
      06-20-2008
I'm trying to emulate the UNIX behavior of system('COMMAND &') on
Windows without having to use fork().

I'd like to avoid this because the overhead of copying all data by
value to the child process is rather substantial. Furthermore, were I
to use fork() I'd eventually having to deal with the unintended
consequences of methods called by the eventual object destruction in
the child process.

Thanks in advance.
 
Reply With Quote
 
 
 
 
Willem
Guest
Posts: n/a
 
      06-20-2008
Jacob JKW wrote:
) I'm trying to emulate the UNIX behavior of system('COMMAND &') on
) Windows without having to use fork().

Why not use the standard windows functionality?
IIRC, it was system('start COMMAND').


SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT
 
Reply With Quote
 
 
 
 
xhoster@gmail.com
Guest
Posts: n/a
 
      06-20-2008
Jacob JKW <(E-Mail Removed)> wrote:
> I'm trying to emulate the UNIX behavior of system('COMMAND &') on
> Windows without having to use fork().


Have you tried:

system(1,'COMMAND')

I don't if it will work for your purposes, but it's the first thing I'd
try.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
 
Reply With Quote
 
Jacob JKW
Guest
Posts: n/a
 
      06-20-2008
On Jun 20, 11:24*am, Willem <(E-Mail Removed)> wrote:
> Jacob JKW wrote:
>
> ) I'm trying to emulate the UNIX behavior of system('COMMAND &') *on
> ) Windows without having to use fork().
>
> Why not use the standard windows functionality?
> IIRC, it was system('start COMMAND').

Because until now I was blissfully unaware of its existence.

It looks very promising. (Only problem is that it seems to pull up a
command window with each invocation.. Clearly not a Perl issue,
however.)

Thank you very much. Highly appreciated.

 
Reply With Quote
 
Jacob JKW
Guest
Posts: n/a
 
      06-20-2008
On Jun 20, 11:40*am, (E-Mail Removed) wrote:
> Jacob JKW <(E-Mail Removed)> wrote:
> > I'm trying to emulate the UNIX behavior of system('COMMAND &') *on
> > Windows without having to use fork().

>
> Have you tried:
>
> system(1,'COMMAND')
>
> I don't if it will work for your purposes, but it's the first thing I'd
> try.

No, I hadn't tried it, but very preliminary testing looks promising.
(I only fear that it may still be a fork() behind the scenes -- I'll
have it to test that further).

But anyway, where is this behavior documented? The perl doc on the
system command doesn't appear to it mention at all.

Many thanks and much appreciated.
 
Reply With Quote
 
Jacob JKW
Guest
Posts: n/a
 
      06-20-2008
On Jun 20, 12:09*pm, Jacob JKW <(E-Mail Removed)> wrote:
> On Jun 20, 11:24*am, Willem <(E-Mail Removed)> wrote:> Jacob JKW wrote:
>
> > ) I'm trying to emulate the UNIX behavior of system('COMMAND &') *on
> > ) Windows without having to use fork().

>
> > Why not use the standard windows functionality?
> > IIRC, it was system('start COMMAND').

>
> It looks very promising. (Only problem is that it seems to pull up a
> command window with each invocation.. Clearly not a Perl issue,
> however.)

Even if clearly not a Perl issue it turns out that the way to avoid
the creation of a new window is with the /B switch so:

system('start /B COMMAND');
 
Reply With Quote
 
Willem
Guest
Posts: n/a
 
      06-20-2008
Jacob JKW wrote:
) No, I hadn't tried it, but very preliminary testing looks promising.
) (I only fear that it may still be a fork() behind the scenes -- I'll
) have it to test that further).
)
) But anyway, where is this behavior documented? The perl doc on the
) system command doesn't appear to it mention at all.

This basically has nothing to do with perl.

start is a windows CLI command.
I think you can type 'help start' in a dos box.
Or otherwise, websearch for it.

I think there are also options to suppress the popup dosbox,
although that may be in the perl Win32 package.


SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT
 
Reply With Quote
 
Ted Zlatanov
Guest
Posts: n/a
 
      06-20-2008
On Fri, 20 Jun 2008 06:39:54 -0700 (PDT) Jacob JKW <(E-Mail Removed)> wrote:

JJ> I'm trying to emulate the UNIX behavior of system('COMMAND &') on
JJ> Windows without having to use fork().

JJ> I'd like to avoid this because the overhead of copying all data by
JJ> value to the child process is rather substantial. Furthermore, were I
JJ> to use fork() I'd eventually having to deal with the unintended
JJ> consequences of methods called by the eventual object destruction in
JJ> the child process.

To avoid fork penalties, you can fork early and communicate between
processes as needed.

Ted
 
Reply With Quote
 
Jacob JKW
Guest
Posts: n/a
 
      06-20-2008
On Jun 20, 12:17*pm, Willem <(E-Mail Removed)> wrote:
> Jacob JKW wrote:
>
> ) No, I hadn't tried it, but very preliminary testing looks promising.
> ) (I only fear that it may still be a fork() behind the scenes -- I'll
> ) have it to test that further).
> )
> ) But anyway, where is this behavior documented? The perl doc on the
> ) system command doesn't appear to it mention at all.
>
> This basically has nothing to do with perl.
>
> start is a windows CLI command.
> I think you can type 'help start' in a dos box.
> Or otherwise, websearch for it.
>
> I think there are also options to suppress the popup dosbox,
> although that may be in the perl Win32 package.

The post to which you're replying was my reply to xhos post where he
had suggested system(1,COMMAND);

I was asking where *that* was documented.

Perhaps I need a better news client than Google.
 
Reply With Quote
 
xhoster@gmail.com
Guest
Posts: n/a
 
      06-20-2008
Jacob JKW <(E-Mail Removed)> wrote:
> On Jun 20, 11:40=A0am, (E-Mail Removed) wrote:
> > Jacob JKW <(E-Mail Removed)> wrote:
> > > I'm trying to emulate the UNIX behavior of system('COMMAND &') =A0on
> > > Windows without having to use fork().

> >
> > Have you tried:
> >
> > system(1,'COMMAND')
> >
> > I don't if it will work for your purposes, but it's the first thing I'd
> > try.


> No, I hadn't tried it, but very preliminary testing looks promising.
> (I only fear that it may still be a fork() behind the scenes -- I'll
> have it to test that further).


I don't think it uses fork, as I don't think windows *has* a real fork.
Perl's fork on windows is emulated using threads, but I doubt they used
used that emulation to implement system(1,...). The point of having
a special system(1,..) on Windows is to use a technology which is better
matched to the underlying OS.

> But anyway, where is this behavior documented? The perl doc on the
> system command doesn't appear to it mention at all.


It is in the "system" section of perldoc perlport. It probably should
be mentioned under perldoc -f system as well, and maybe perldoc -q
background.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows XP 64 Emulating 32bit Mode tekki Windows 64bit 2 12-12-2007 02:48 PM
Emulating variables static to the page Mike Orb ASP .Net 2 09-02-2005 03:24 PM
Emulating floating point gthorpe@ee.ryerson.ca VHDL 3 09-01-2005 09:03 PM
Emulating axis "following-sibling-or-self" without union? Niall Smart XML 1 03-05-2004 07:35 PM
Emulating progressive image loading for IE using Javascript Chris Jakeman Javascript 1 07-17-2003 08:03 AM



Advertisments