On Tue, Oct 8, 2013 at 5:02 PM, Peter Hitchman <[email protected]> wrote:
> On 6 October 2013 13:44, Cedric Blancher <[email protected]> wrote:
>> On 6 October 2013 10:36, Peter Hitchman <[email protected]> wrote:
>> > Hi
>> > I am using Version JM 93t+ 2010-06-21 on RHL4.
>> > I have been playing around with a co-process and what happens when the
>> > co-process dies.
>> > What I have found is that to have any control I have to catch SIGPIPE in
>> > a
>> > function,
>> > but that I cannot then continue processing outside of this function, all
>> > I
>> > can do is exit the script.
>> >
>> > Is this the right way to do it?
>>
>> Do you have any example code which shows what you are trying to do?
>
> OK I'll work up a simple example, what I have now is to much to post.
> The background is that I am connecting to an Oracle database using sqlplus
> as a co-process and seeing what happens when for some reason the db
> connection goes away. I found that I had to trap SIGPIPE.
Erm... does the example below help somehow (it requires a newer
ksh93v- version since .sh.sig is a new feature in that version) ?
-- snip --
$ ksh -x -c 'builtin pids ; trap "print -v .sh.sig ; kill -l
\${.sh.sig.status}" CHLD ; { thispid=${ pids -f "%(pid)d" ; } ; kill
-s ABRT $thispid ; } & ; wait ; print $? ; true'
+ builtin pids
+ trap 'print -v .sh.sig ; kill -l ${.sh.sig.status}' CHLD
+ wait
+ pids -f '%(pid)d'
+ thispid=1966
+ kill -s ABRT 1966
+ print -v .sh.sig
(
typeset -r -l -i 16 addr=16#3e8000007ae
typeset -r -l -i band=0
typeset -r code=KILLED
typeset -r -i errno=0
typeset -r name=CHLD
typeset -r -i pid=1966
typeset -r -i signo=17
typeset -r -i status=6
typeset -r -i uid=1000
value=(
typeset -r -i q=6
typeset -r -l -u -i Q=6
)
)
+ kill -l 6
ABRT
+ print 1
1
+ true
-- snip --
... it shows a process child killing itself using SIGABORT (kill -s
ABRT and uses the pids(1) builtin to figure out the process id of the
child process) and the CHLD trap first prints the contents of the
.sh.sig compound variable (which is ksh93's variation of the POSIX
siginfo data) and then uses the .sh.sig.signo variable to figure out
which signal (or better: The name of the signal which...) killed the
child process (using $ kill -l ${signal_number} #).
----
Bye,
Roland
--
__ . . __
(o.\ \/ /.o) [email protected]
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL +49 641 3992797
(;O/ \/ \O;)
_______________________________________________
ast-users mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-users