Marcus Leech writes:

> I experimentally put some code just before the execvpe() in
> inject.py to close FDs >= 3 and <= 10.  I picked 10 out of
> the air, but I wouldn't expect there to be many open file
> descriptors at that point.  Actually, given the semantics of dup(),
> you could use it to probe what the maximum FD number is just before
> execvpe(), so the terminating condition could be something
> like <= dup(0).

I don't see how dup() would help you. Remember, you could get
back fd 123 even if fd 12345 was the last one allocated and is
still in use. You get the lowest free fd.

You can do readdir() on /proc/self/fd to list them, being
careful to not close the fd used for reading the directory
until you have read the whole directory.
_______________________________________________
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel

Reply via email to