dh_installinit - Debian

This is a discussion on dh_installinit - Debian ; Hi On Sun, 11 Nov 2007 20:31:55 -0700 Tim Spriggs wrote: > Is there no way of listing open file handles within a process? It seems > like there should be a better way. If the kernel knows what file ...

+ Reply to Thread
Page 2 of 2 FirstFirst 1 2
Results 21 to 24 of 24

Thread: dh_installinit

  1. Re: dh_installinit

    Hi

    On Sun, 11 Nov 2007 20:31:55 -0700
    Tim Spriggs wrote:

    > Is there no way of listing open file handles within a process? It seems
    > like there should be a better way. If the kernel knows what file handles
    > exist (and lsof can get the info) then what's stopping a process from
    > accessing that information directly? Maybe it's just not portable enough?


    You can definitely get it from /proc, but it is far from being portable.

    --
    Michal Čihař | http://cihar.com | http://blog.cihar.com

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.6 (GNU/Linux)

    iD8DBQFHN9Fy3DVS6DbnVgQRAnSuAKCd7LwLTHJw3q/5X8/yguiR/setHACfRSCN
    P0RMXXZUinjUFd+d64lQ7dY=
    =6S+G
    -----END PGP SIGNATURE-----


  2. Re: dh_installinit

    On 11-Nov-07, 14:25 (CST), Arthur de Jong wrote:
    >
    > This seems to be quite common code (from one of my packages (cvsd),
    > don't know what the original source for this code was):
    >
    > m=sysconf(_SC_OPEN_MAX);
    > for (i=0;i > close(i);
    >
    > There are hurd packages for this package so that should also work.


    Wrong. That code is buggy. The limit of OPEN_MAX can be indeterminate,
    and thus sysconf(_SC_OPEN_MAX) can return -1.

    Steve

    --
    Steve Greenland
    The irony is that Bill Gates claims to be making a stable operating
    system and Linus Torvalds claims to be trying to take over the
    world. -- seen on the net


    --
    To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
    with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

  3. Re: dh_installinit


    On Mon, 2007-11-12 at 12:34 -0600, Steve Greenland wrote:
    > On 11-Nov-07, 14:25 (CST), Arthur de Jong wrote:
    > > This seems to be quite common code (from one of my packages (cvsd),
    > > don't know what the original source for this code was):
    > >
    > > m=sysconf(_SC_OPEN_MAX);
    > > for (i=0;i > > close(i);
    > >
    > > There are hurd packages for this package so that should also work.

    >
    > Wrong. That code is buggy. The limit of OPEN_MAX can be indeterminate,
    > and thus sysconf(_SC_OPEN_MAX) can return -1.


    Thanks, fixed that in my code (if the call returns negative, we just
    close the first 32 file descriptors and hope that's enough).

    Anyone have a better way to detect the highest open file descriptor
    (preferably something that also works inside a chroot jail that does not
    have /proc mounted)? NetBSD seems to have fcntl(F_MAXFD) that should do
    the trick, but it's unavailable on Linux.

    --
    -- arthur - adejong@debian.org - http://people.debian.org/~adejong --

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.6 (GNU/Linux)

    iD8DBQBHOMz5VYan35+NCKcRAh71AKCjTNtDgz1a9+Y90cpyFe hYTxuHLACgvC8R
    9xS96biAKjWFDmjVExILRCE=
    =Gj72
    -----END PGP SIGNATURE-----


  4. Re: dh_installinit

    On Nov 12, 2007 11:00 PM, Arthur de Jong wrote:
    > Anyone have a better way to detect the highest open file descriptor
    > (preferably something that also works inside a chroot jail that does not
    > have /proc mounted)? NetBSD seems to have fcntl(F_MAXFD) that should do
    > the trick, but it's unavailable on Linux.


    If we do find a method that works, it seems sensibile to make a simple
    LD_PRELOAD library you can set that will spit out warnings whenever
    extra file descriptiors are left open. The FD_CLOEXEC flag exists for
    a reason and most cases to probably bugs.

    Have a nice day,
    --
    Martijn van Oosterhout http://svana.org/kleptog/


    --
    To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
    with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

+ Reply to Thread
Page 2 of 2 FirstFirst 1 2