Hi!

----

This seems to be a very old bug (I can trace it to at least
ast-ksh.2011-02-08) ...
... it seems that ksh93 doesn't close file descriptors opened in a
subshell if the fd number is > 10.

Example (in Solaris $ /usr/proc/bin/pfiles <pid> # will print all open
file fds for a given process):
-- snip --
$ ksh -c 'cd /etc/inet ; ( redirect {n}</etc/profile ; true ); pfiles
$$ ; true'
21998:  ksh -c cd /etc/inet ; ( redirect {n}</etc/profile ; true ); pfiles $$
  Current rlimit: 256 file descriptors
   0: S_IFCHR mode:0620 dev:552,0 ino:439399504 uid:1000 gid:7 rdev:6,1
      O_RDWR|O_NOCTTY|O_LARGEFILE
      /dev/pts/1
      offset:17168464
   1: S_IFCHR mode:0620 dev:552,0 ino:439399504 uid:1000 gid:7 rdev:6,1
      O_RDWR|O_NOCTTY|O_LARGEFILE
      /dev/pts/1
      offset:17168464
   2: S_IFCHR mode:0620 dev:552,0 ino:439399504 uid:1000 gid:7 rdev:6,1
      O_RDWR|O_NOCTTY|O_LARGEFILE
      /dev/pts/1
      offset:17168464
  10: S_IFREG mode:0644 dev:90,65538 ino:27285 uid:0 gid:3 size:1570
      O_RDONLY|O_LARGEFILE FD_CLOEXEC
      /etc/profile
      offset:0
-- snip --

This only happens for fd >=10 ...

Testcase is:
-- snip --
# this fails
$ ksh -c 'cd /etc/inet ; ( redirect {n}</etc/profile ; true ); [[ -f
/dev/fd/10 ]] && printf "file is open\n"; true'
file is open
# this prints nothing (as expected):
$ ksh -c 'cd /etc/inet ; ( ulimit -c 0 ; redirect {n}</etc/profile ;
true ); [[ -f /dev/fd/10 ]] && printf "file is open\n"; true'
-- snip --

----

Bye,
Roland

-- 
  __ .  . __
 (o.\ \/ /.o) [email protected]
  \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
  /O /==\ O\  TEL +49 641 3992797
 (;O/ \/ \O;)
_______________________________________________
ast-developers mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-developers

Reply via email to