On Fri, Oct 26, 2012 at 04:42:17PM +0200, Roland Mainz wrote: > On Fri, Oct 26, 2012 at 3:47 PM, Dr. Werner Fink <wer...@suse.de> wrote: > > I had a customer which had reported that the ksh run into problem if > > the /tmp partition on his system had no space left due to a process > > gone wild: > > > > Last login: Tue Oct 23 15:12:00 2012 from ... > > /etc/profile: line 12: write to 1 failed [No space left on device] > > /etc/profile: line 41: write to 1 failed [No space left on device] > > /etc/profile: line 87: write to 1 failed [No space left on device] > > /etc/profile: line 88: write to 1 failed [No space left on device] > > /etc/profile: line 91: write to 1 failed [No space left on device] > > /etc/profile: line 92: write to 1 failed [No space left on device] > > /etc/profile: line 93: write to 1 failed [No space left on device] > > /usr/bin/manpath: can't set the locale; make sure $LC_* and $LANG are > > correct > > /etc/profile: line 207: write to 1 failed [No space left on device] > > /etc/profile[324]: .: line 606: write to 4 failed [No space left on > > device] > > > > also the ksh93u-2012-02-29 sometimes crash in src/cmd/ksh93/sh/subshell.c > > which seems to be fixed in current ksh. Nevertheless IMHO the ksh should > > check not only if access is allowed in /tmp or /usr/tmp (which points to > > /var/tmp) but also if there is enough room left. If no space is left on > > the temporary device it would be perfect to use pipe() as fallback for > > stdout. > > Uhm... for which shell constructs would you like to use |pipe()| ?
if ! is=$(/bin/ls -l /proc/$$/exe 2>/dev/null) ; then [...] tty=`tty 2> /dev/null` [...] test -z "$UID" && readonly UID=`id -ur 2> /dev/null` test -z "$EUID" && readonly EUID=`id -u 2> /dev/null` [...] test -z "$HOST" && HOST=`/bin/hostname -s 2> /dev/null` test -z "$CPU" && CPU=`/bin/uname -m 2> /dev/null` test -z "$HOSTNAME" && HOSTNAME=`/bin/hostname 2> /dev/null` [...] MANPATH="`test -x /usr/bin/manpath && /usr/bin/manpath -q`" [...] Btw: from src/cmd/ksh93/sh/subshell.c you can see in sh_subtmpfile() that if the creation of a tmp fd fails a pipe is usesd: /* popping a discipline forces a /tmp file create */ sfdisc(sfstdout,SF_POPDISC); if((fd=sffileno(sfstdout))<0) { /* unable to create the /tmp file so use a pipe */ [...] > > > See the attached patch for a suggested solution. The change in > > src/lib/libast/path/pathtemp.c uses statvfs() to check if the device > > has at least space of the sitze of one page left. The change in > > src/lib/libast/sfio/sftmp.c use the /dev/shm tmpfs which is used for > > POSIX shared memory objects. One could use shm_open()/shm_unlink() > > but the file descriptor then has FD_CLOEXEC set in its flags. > > A different solution (since /dev/shm is not portable) may be to probe > various locations for temporary files and check if there is space left > (e.g. /tmp (preferred because this is usually a ramdisk-like > filesystem on newer Unixes), /var/tmp and /usr/tmp (the traditional > location)) and check if at least a page (MMU default page size) is > available (a better algorithm may be 8*default_mmu_page_size) ... if > all locations do not have enough space then ksh93 should bail-out with > a fatal error... With glibc there exists also the functions shm_open(3) and shm_unlink(3) but the open for POSIX SHM will set the FD_CLOEXEC flag on the fd. Both shm_open(3) and shm_unlink(3) handle files relatively to /dev/shm. Werner -- "Having a smoking section in a restaurant is like having a peeing section in a swimming pool." -- Edward Burr _______________________________________________ ast-developers mailing list ast-developers@research.att.com https://mailman.research.att.com/mailman/listinfo/ast-developers