Milan Jurik wrote: > Roland Mainz p????e v po 02. 03. 2009 v 18:50 +0100: > > Milan Jurik wrote: > > > V po, 02. 03. 2009 v 17:25, Roland Mainz p?f??????e: [snip] > And there is really something wrong, I tried to minimize the test case, > see this log: > > mj162486 at xylabone:~$ ksh93 > mj162486 at xylabone:~$ print -u 2 "Test" > tee /tmp/test > Test /tmp/test > mj162486 at xylabone:~$ cat /tmp/test > mj162486 at xylabone:~$ tee /tmp/test; print "Test" > > - here I used Ctrl+c > > mj162486 at xylabone:~$ rm tee > mj162486 at xylabone:~$ print -u 2 "Test" | tee /tmp/test > Segmentation Fault (core dumped) > mj162486 at xylabone:~$ > mj162486 at xylabone:~$ > mj162486 at xylabone:~$ ksh93 > mj162486 at xylabone:~$ tee /tmp/test; print "Test" > mj162486 at xylabone:~$ > mj162486 at xylabone:~$ rm /tmp/test > mj162486 at xylabone:~$ ksh93 > mj162486 at xylabone:~$ touch /tmp/test > mj162486 at xylabone:~$ tee /tmp/test; print "Test" > mj162486 at xylabone:~$ rm tee > rm: tee: No such file or directory > mj162486 at xylabone:~$ > > - here I put Ctrl+d > > Segmentation Fault (core dumped)
Ok... at least half the problem is caused by interupting the "tee" builtin via <ctrl-c> - in this case the fd will not be closed. Example: -- snip -- # start ksh93: $ ksh93 # run "tee" builtin $ tee /tmp/hello # get list of opened files via /proc-tools $ pfiles $$ 1467: ./arch/sol11.sun4/bin/ksh Current rlimit: 256 file descriptors 0: S_IFCHR mode:0620 dev:358,0 ino:45929285 uid:1000 gid:7 rdev:24,4 O_RDWR|O_NOCTTY|O_LARGEFILE /dev/pts/4 1: S_IFCHR mode:0620 dev:358,0 ino:45929285 uid:1000 gid:7 rdev:24,4 O_RDWR|O_NOCTTY|O_LARGEFILE /dev/pts/4 2: S_IFCHR mode:0620 dev:358,0 ino:45929285 uid:1000 gid:7 rdev:24,4 O_RDWR|O_NOCTTY|O_LARGEFILE /dev/pts/4 3: S_IFDOOR mode:0444 dev:368,0 ino:57 uid:0 gid:0 size:0 O_RDONLY|O_LARGEFILE FD_CLOEXEC door to nscd[142] /var/run/name_service_door 4: S_IFREG mode:0600 dev:32,7 ino:8055 uid:1000 gid:100 size:917283 O_RDWR|O_APPEND|O_CREAT|O_LARGEFILE FD_CLOEXEC /home/test001/.sh_history 5: S_IFREG mode:0644 dev:362,2 ino:45413797 uid:1000 gid:100 size:0 O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE /tmp/hello $ exit Illegal instruction(coredump) -- snip -- The stack trace looks like this: -- snip -- [1] _kill(0x0, 0x4, 0x0, 0x0, 0x400, 0x3), at 0xffffffff7e9d0e40 =>[2] sh_done(ptr = 0x10032e800, sig = 4), line 628 in "fault.c" [3] sh_fault(sig = 4), line 139 in "fault.c" [4] __sighndlr(0x4, 0x0, 0xffffffff7fffec20, 0x10002ab60, 0x0, 0x0), at 0xffffffff7e9cc4e4 ---- called from signal handler with signal 4 (SIGILL) ------ [5] 0x100352558(0x1003323b8, 0x0, 0x1, 0x10034ece0, 0xffffffff7f7365f8, 0x2), at 0x100352558 [6] sfsetbuf(f = 0x1003323b8, buf = (nil), size = 0), line 212 in "sfsetbuf.c" [7] _sfcleanup(), line 102 in "sfmode.c" [8] _exithandle(0xffffffff7eb63bc0, 0xffffffff7ffff3e0, 0xffffffff7eb61fc0, 0x1c00, 0x0, 0x2f23), at 0xffffffff7e95b670 [9] exit(0x0, 0x100350ff0, 0x0, 0x400, 0x400, 0x100041ddc), at 0xffffffff7e94abc8 [10] sh_done(ptr = 0x10032e800, sig = 0), line 635 in "fault.c" [11] exfile(shp = 0x10032e800, iop = 0x100332308, fno = 0), line 612 in "main.c" [12] sh_main(ac = 1, av = 0xffffffff7ffffaa8, userinit = (nil)), line 366 in "main.c" [13] main(argc = 1, argv = 0xffffffff7ffffaa8), line 46 in "pmain.c" -- snip -- AFAIK two things need to be done: 1. The "tee" builtin needs code which runs _always_ when the command exists to close all fds opened by it. 2. The Tee discipline may need an exception hook (currently it only has a callback for writes (e.g. |tee_write()|) to handle errors better. ---- Bye, Roland -- __ . . __ (o.\ \/ /.o) roland.mainz at nrubsig.org \__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer /O /==\ O\ TEL +49 641 3992797 (;O/ \/ \O;)