Quote:
Originally Posted by porter
If you can't fork you can't run a command in a shell to see why it can't fork, as it needs to fork to create the process to run the command in.
First, reborg suggested arranging for a command to run every five minutes which might show /tmp filling prior to being totally filled. And it is possible for a large process to be unable to fork while smaller processes have no problem. This is actually quite common. Finally, it is not exactly true that a shell must fork to run a command. A shell is programming language with lots of built in commands. Can't launch ls?
$ myls() { while [ $# -ne 0 ] ; do echo "$1" ; shift ; done ; }
$ myls /etc/s*
/etc/services
/etc/shells
/etc/syslog.conf
$
Can't launch cat?
$ mycat() { while IFS="" read l ; do echo "$l" ; done < $1 ; }
$ mycat /etc/shells
#
# This is a list of valid login shells (single rooted).
# Ftpd must see one of these shells as a user's login shell to connect.
#
/bin/sh
/bin/ksh
/bin/csh
/bin/tcsh
/usr/local/bin/bash
$
None of that needed a single fork provided I use ksh. I can conjure up limited versions of quite a few commands this way. And if I am desperate to diagnose a stalled OS before I cycle power, I have a final trick...I can run a single command by using exec...
exec df -k
A box that cannot fork can often exec.