Operating System - HP-UX
1837191 Members
2534 Online
110114 Solutions
New Discussion

Re: Shell program / Wrapper Needed to gracefully shutdown the session gracefully

 
Hunki
Super Advisor

Shell program / Wrapper Needed to gracefully shutdown the session gracefully

I have been working on tuxedo for the past two months, and there we have this queue admin utility called qmadmin, which if it recieves a signal 9 , 15 ,1,2,6...( when it is open )it makes the tuxedo hung up and no processing of the queue is carried out.
From a Unix perspective when I asked one of the system admin , he told me the following :
"Basically run a C wrapper (or shell???) program around the qmadmin command that catches any shell disconnect/kill signal...then within that function it disconnects/exits the qmadmin session gracefully."

As I am very limited on C , what are the options open to me to actually make this happen through a shell script.
We have to do a quit in the qmadmin utility to gracefully shut it down.

Thanks to all nice and smart samaritans.
7 REPLIES 7
paolo barila
Valued Contributor

Re: Shell program / Wrapper Needed to gracefully shutdown the session gracefully

# man trap

Multiple signal numbers can be placed on the same trap command. For example,

trap 'rm $TMP' 0 1 2 3 15

executes the rm $TMP command if any one of the 0, 1, 2, 3, or 15 signals are caught.
share share share
Hunki
Super Advisor

Re: Shell program / Wrapper Needed to gracefully shutdown the session gracefully

I am aware of trap, but I am looking for a more exhaustive input , if you look at my post what I am looking for is a wrapper that trigers a function to exit the qmadmin session gracefully.It does not work well with the 15 signal.

Thanks
Hunki
Super Advisor

Re: Shell program / Wrapper Needed to gracefully shutdown the session gracefully

Basically, I want to trap the signals (9,15)on the qmadmin command and make it quit gracefully.
Mark Ellzey
Valued Contributor

Re: Shell program / Wrapper Needed to gracefully shutdown the session gracefully

Hi,

It's very simple.

# cat qrnadmin_start

#!/usr/bin/sh
trap "[shutdown qrnadmin commands]" 9 15
[start qrnamdin commands]

You can then start you qrnadmin session with the qrnamdin_start script. The script catches either sig 9 or sig 15, it will execute the shutdown commands.

Regards,
Mark
Hunki
Super Advisor

Re: Shell program / Wrapper Needed to gracefully shutdown the session gracefully

Qmadmin can be quit through the session only.What I mean is that through pressing q ( for quit ) to quit the session.There is not command to actually shut it down.

Hunki
Super Advisor

Re: Shell program / Wrapper Needed to gracefully shutdown the session gracefully

When I do a truss qmadmin , the following is the output when I key in q ( for quit ) :

truss qmadmin

....

read(0, " q\n", 1024) = 2
_exit(0)

When I did a man kill , I found this info :

exit_status
A decimal integer specifying a signal number or
the exit status of a process terminated by a signal.

Can any of the stuff that is there in "truss qmadmin" be passed thru to kill ( or any other means ) that it gracefully shuts down the process.

Thanks.
Hunki
Super Advisor

Re: Shell program / Wrapper Needed to gracefully shutdown the session gracefully

Temp Closing.
Opened a Case with BEA.