For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > January 2007 > Re: fork/exec vs system









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: fork/exec vs system
Connie

2007-01-24, 7:07 pm

Hi Jens,
Thank you very much for your reply. I heard that Perl by deafult sets
close-on-exec for all descriptors except
STDIN STDOUT and STDERR. If that is true, I shouldn't worry about the
inherit handles since I use perl(Although I like C better.;-)

Thanks
-Connie


On Jan 24, 2:14 pm, j...@toerring.de (Jens Thoms Toerring) wrote:
> Connie <yecon...@gmail.com> wrote:
> exec()ing a shell that in turn tries to start the program
> specified as the argument of system).
>
> to safe-guard against possible problems resulting from the child
> process inheriting open files is to set the close-on-exec flag
> for all files the parent has open.
>
> If you need that it's probably better to use fork/exec instead of
> system().
> Regards, Jens
> --
> \ Jens Thoms Toerring ___ j...@toerring.de
> \__________________________ http://toerring.de


Jens Thoms Toerring

2007-01-24, 7:07 pm

Connie <yeconnie@gmail.com> wrote:
> I heard that Perl by deafult set close-on-exec for all descriptors except
> STDIN STDOUT and STDERR. If that is true,


Looks like that's the case, see p. 423ff in the Camel book (3rd ed.).
You seem to have to clear the close-on-exec flag to make sure the
file gets inherited by an exec()ed process (or diddle with the $^F
variable while opening the file).

Regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com