Unix Programming - Re: fork/exec vs system

This is Interesting: Free IT 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
Jens Thoms Toerring

2007-01-24, 7:19 pm

Connie <yeconnie@gmail.com> wrote:
> I just notice that some other programs might call my PERL script, so I
> still have to solve this issue.


You mean your PERL script will be exec()ed by other (non-Perl)
programs? Then I guess you shouldn't have to worry too much about
that, the callers should consider which file descrptors they want
to leak to an exec()ed program, they shouldn't expect you to do
their cleaning up. Mentioning this as a possible problem might
be nice - but actively closing files is not necessarily the
right thing to do. Perhaps someone clever actually wants one
of the files to be inherited by the child process you exec()
and why would you keep her or him from doing that?

> Close-on-exec has to be set by developers, is there a good way to
> get all the opened handles and close them after I call fork?


I fear that would be rather difficult to do in a portable way.
I guess you would have to iterate over all possible file des-
criptor numbers and check for each of them if its an open file.

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






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com