Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

RE: PATCH: Re: zpty and controlling tty (and other fd's)



>
> On True64 Unix O_NOCTTY is implicit and cannot be unset. How weird.
>

Hmm ... if I correctly recall, first tty opened by process becomes
controlling tty. It means, that if child has closed all of it's file
descriptors and reopens tty for stdin (duplicating it for stdout,
stderr) - it gets it as controlling tty. It should be fairly portable.
And closing all descriptors is probably needed anyway because ...

> >
> > Oh, yes, and why nslookup has fd's 10 and 11 open at all?
>
> Missing close()s? (The parent shell's stdio descriptors.)
>

... there is more that remains from parent:

bor@itsrm2% lsof -c nslookup
COMMAND    PID USER   FD   TYPE DEVICE SIZE/OFF  NODE NAME
nslookup 15216  bor  cwd   VDIR    4,5     3072   125 /home/bor
nslookup 15216  bor  txt   VREG    4,3    69961 46376 /usr/sbin/nslookup
nslookup 15216  bor  txt   VREG    4,3   715161 23840 /usr/lib/libc.so.1
nslookup 15216  bor  txt   VREG    4,3   320397 23882
/usr/lib/libresolv.so
nslookup 15216  bor  txt   VREG    4,3   192333 23859
/usr/lib/libsocket.so
nslookup 15216  bor  txt   VREG    4,3   592617 26181 /usr/lib/libnsl.so
nslookup 15216  bor    0u  VCHR 112,10     0t66  4204
STR:/dev/pts/10->pts
nslookup 15216  bor    1u  VCHR 112,10     0t66  4204
STR:/dev/pts/10->pts
nslookup 15216  bor    2u  VCHR 112,10     0t66  4204
STR:/dev/pts/10->pts
nslookup 15216  bor    3u  VCHR 111,10     0t69       STR:/dev/ptmx->ptm
nslookup 15216  bor   13r  VREG    4,5  1303776 24152
/home/bor/.zsh.d/std-3.1.7-pre-2.zwc

Note fd's 3 and 13. 3 is master side of pty (child does not need it,
does it?) And 13 is left over from wordcode file mapping. Mapping itself
goes away after exec (at least here - I expect, it should be true for
all Unices) - but we have to close fd anyway.

-andrej



Messages sorted by: Reverse Date, Date, Thread, Author