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

Re: PATCH: coprocess descriptor and error messages



On Sep 17,  9:46am, Peter Stephenson wrote:
}
} The question is whether it's useful to be able to test whether the
} coprocess is open at the same time as attempting to read or write.

Is there another obvious way to test whether the coprocess is open?

Aside:  Should an interactive shell ever exit on SIGPIPE?  Or maybe
a better question is, should a print to the coprocess ever cause an
un-trapped SIGPIPE?

schaefer[713] Src/zsh -f
torch% coproc repeat 8 read -E
[1] 31339
torch% repeat 10 { print -p; read -p }
schaefer[714] echo $?
141

} If so, doing it silently is reasonable. Otherwise it might be less
} mysterious to print "coprocess not open", or something like that,
} in both cases.

In looking further, the coprocess descriptor is reset to -1 only (and
immediately) by "read -p" detecting EOF on the coprocess output.  So
in the "read" case, the invalid descriptor has always served as an
EOF flag.  What should happen if the parent attempts to read after
an EOF has been seen?  I would tend to think it should just get EOF
again, not produce a diagnostic, which is the current behavior. 

However, ksh (at least pdksh) disagrees with me:

$ print -p
ksh: print: -p: no coprocess
$ read |&
[1] 31399
$ print -p
$ print -p
ksh: print: -p: no coprocess
[1] + Done                 read 
$ read -p
$ read -p
ksh: read: -p: no coprocess
$ print -p
ksh: print: -p: no coprocess
$ 

Note, however, that it does NOT exit with SIGPIPE on "print -p".



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