NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bin/44722



The following reply was made to PR bin/44722; it has been noted by GNATS.

From: Alan Barrett <apb%cequrux.com@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: bin/44722
Date: Sun, 18 Sep 2011 11:14:48 +0200

 On Sat, 17 Sep 2011, Abhinav Upadhyay wrote:
 > Not only ls(1) but probably a number of other programs are not behaving
 > correclty under low file descriptor limit.
 > For example:
 >
 > $ man ls
 > .: 4: Invalid argument
 
 I can't replicate that.  I get the following results, with everything
 either working or giving a reasonable error:
 
 for ENV in '' /etc/shrc ; do
      for PAGER in '' cat more ; do
        for n in 5 4 3 2 1 ; do
            cmd="env - PATH=\\\"\\\$PATH\\\""
            cmd="${cmd}${ENV:+ ENV=\"\$ENV\"}"
            cmd="${cmd}${PAGER:+ PAGER=\"\$PAGER\"}"
            cmd="${cmd} sh -c \\'ulimit -n ${n}\; man ls\\'"
            [ -z "$PAGER" ] && cmd="${cmd} \| cat"
            eval echo "\$ ${cmd}"
            eval eval "${cmd}"
        done
        echo
      done
 done
 
 $ env - PATH="$PATH" sh -c 'ulimit -n 5; man ls' | cat
 [works]
 $ env - PATH="$PATH" sh -c 'ulimit -n 4; man ls' | cat
 [works]
 $ env - PATH="$PATH" sh -c 'ulimit -n 3; man ls' | cat
 Shared object "libutil.so.7" not found
 $ env - PATH="$PATH" sh -c 'ulimit -n 2; man ls' | cat
 Shared object "libutil.so.7" not found
 $ env - PATH="$PATH" sh -c 'ulimit -n 1; man ls' | cat
 Shared object "libutil.so.7" not found
 
 $ env - PATH="$PATH" PAGER=cat sh -c 'ulimit -n 5; man ls'
 [works]
 $ env - PATH="$PATH" PAGER=cat sh -c 'ulimit -n 4; man ls'
 [works]
 $ env - PATH="$PATH" PAGER=cat sh -c 'ulimit -n 3; man ls'
 Shared object "libutil.so.7" not found
 $ env - PATH="$PATH" PAGER=cat sh -c 'ulimit -n 2; man ls'
 Shared object "libutil.so.7" not found
 $ env - PATH="$PATH" PAGER=cat sh -c 'ulimit -n 1; man ls'
 Shared object "libutil.so.7" not found
 
 $ env - PATH="$PATH" PAGER=more sh -c 'ulimit -n 5; man ls'
 [works]
 $ env - PATH="$PATH" PAGER=more sh -c 'ulimit -n 4; man ls'
 /usr/share/man/cat1/ls.0: Too many open files
 [error message is from more(1)]
 $ env - PATH="$PATH" PAGER=more sh -c 'ulimit -n 3; man ls'
 Shared object "libutil.so.7" not found
 $ env - PATH="$PATH" PAGER=more sh -c 'ulimit -n 2; man ls'
 Shared object "libutil.so.7" not found
 $ env - PATH="$PATH" PAGER=more sh -c 'ulimit -n 1; man ls'
 Shared object "libutil.so.7" not found
 
 $ env - PATH="$PATH" ENV=/etc/shrc sh -c 'ulimit -n 5; man ls' | cat
 [works]
 $ env - PATH="$PATH" ENV=/etc/shrc sh -c 'ulimit -n 4; man ls' | cat
 [works]
 $ env - PATH="$PATH" ENV=/etc/shrc sh -c 'ulimit -n 3; man ls' | cat
 Shared object "libutil.so.7" not found
 $ env - PATH="$PATH" ENV=/etc/shrc sh -c 'ulimit -n 2; man ls' | cat
 Shared object "libutil.so.7" not found
 $ env - PATH="$PATH" ENV=/etc/shrc sh -c 'ulimit -n 1; man ls' | cat
 Shared object "libutil.so.7" not found
 
 $ env - PATH="$PATH" ENV=/etc/shrc PAGER=cat sh -c 'ulimit -n 5; man ls'
 [works]
 $ env - PATH="$PATH" ENV=/etc/shrc PAGER=cat sh -c 'ulimit -n 4; man ls'
 [works]
 $ env - PATH="$PATH" ENV=/etc/shrc PAGER=cat sh -c 'ulimit -n 3; man ls'
 Shared object "libutil.so.7" not found
 $ env - PATH="$PATH" ENV=/etc/shrc PAGER=cat sh -c 'ulimit -n 2; man ls'
 Shared object "libutil.so.7" not found
 $ env - PATH="$PATH" ENV=/etc/shrc PAGER=cat sh -c 'ulimit -n 1; man ls'
 Shared object "libutil.so.7" not found
 
 $ env - PATH="$PATH" ENV=/etc/shrc PAGER=more sh -c 'ulimit -n 5; man ls'
 [works]
 $ env - PATH="$PATH" ENV=/etc/shrc PAGER=more sh -c 'ulimit -n 4; man ls'
 /usr/share/man/cat1/ls.0: Too many open files
 [error message is from more(1)]
 $ env - PATH="$PATH" ENV=/etc/shrc PAGER=more sh -c 'ulimit -n 3; man ls'
 Shared object "libutil.so.7" not found
 $ env - PATH="$PATH" ENV=/etc/shrc PAGER=more sh -c 'ulimit -n 2; man ls'
 Shared object "libutil.so.7" not found
 $ env - PATH="$PATH" ENV=/etc/shrc PAGER=more sh -c 'ulimit -n 1; man ls'
 Shared object "libutil.so.7" not found
 
 > The error messages suggest that probably something is going wrong with
 > the shell. Probably the shell tries to execute the shell built-in '.'
 > (as observed by the above error message).
 
 I can get error messages similar to that from the shell, but not using
 the "man ls" command.  For example:
 
 $ env - PATH="$PATH" sh -c 'ulimit -n 4 ; . /etc/shrc'
 .: 3: Invalid argument
 
 The error message could be better, but otherwise the behaviour
 seems reasonable.
 
 > It was even more weird to see that ls(1) and man(1) exited with proper
 > error messages if I tried to do something like this:
 >
 > $ . ls #supply name of any executable file
 > .: Cannot execute ELF binary /bin/ls
 >
 > $ ls
 > ls: .: Too many open files
 >
 > $ man sh
 > .: Can't open /etc/shrc
 
 Those error messages seem reasonable to me.
 
 --apb (Alan Barrett)
 


Home | Main Index | Thread Index | Old Index