[Wellington-pm] question about 'system', and other methods for calling os functions
Richard Hector
richard at walnut.gen.nz
Tue Apr 19 17:14:09 PDT 2011
On Tue, 2011-04-19 at 22:37 +1200, Ewen McNeill wrote:
> You may be able to explicitly set the (unix) FD_CLOEXEC flag on the
> relevant file descriptors before the system() call (which should be
> doing fork()/exec()/other stuff under the hood on a Linux system), sort
> of like the reverse of the example towards the end of this page:
>
> http://aaroncrane.co.uk/talks/pipes_and_processes/
>
> but I'm not sure it's worth the effort.
Yes, I found that (FD_CLOEXEC, not the link) last night, and was
planning to try it ...
> That said, I'm unable to find a combination of perl+LVM tools amongst,
> eg, my Debian systems that reproduces that behaviour with:
>
> sudo perl -e 'system("lvdisplay");'
> sudo perl -e 'system("lvcreate");'
... but I figured I'd play with reproducing it in a smaller program, and
eventually managed by adding the line:
my $vmm = Sys::Virt->new(uri => "qemu:///system");
Sys::Virt is an XS wrapper around libvirt, for managing various types of
virtual machines on linux.
So I guess it's opening the extra filehandles - which may well not be
the ones I mentioned earlier. I don't like the idea of hiding warnings,
so I guess I need to re-order the code (so it creates the lvs before
calling Sys::Virt), or confirm which filehandles they are and close them
in a separate process with FD_CLOEXEC. Or something.
Any tips on identifying open filehandles? Google wasn't too helpful on
that :-(
Thanks,
Richard
More information about the Wellington-pm
mailing list