Operating System - HP-UX
1827283 Members
3447 Online
109717 Solutions
New Discussion

How to get and set a signal mask within an unix script.

 
Rui Vilao
Regular Advisor

How to get and set a signal mask within an unix script.

Hi all,

I am having a big trouble within a MC-SG control script.

It looks like MC-SG has masked a signal used by Oracle and HP-OV...

==> Oracle shutdown, OV startup hang.

My questions are:

1. Does anyone know how to get within a shell the signal mask?

2. How can I set a new signal mask within a shell?

Any help is apreciated,

TIA,

Kind Regards,

Rui.
"We should never stop learning"_________ rui.vilao@rocketmail.com
11 REPLIES 11
harry d brown jr
Honored Contributor

Re: How to get and set a signal mask within an unix script.

Do you mean "trap " or setting/catching an "SMNP trap"?


live free or die
harry
Live Free or Die
Sanjay_6
Honored Contributor

Re: How to get and set a signal mask within an unix script.

Hi Rui,

What is it that you are trying to do. We have oracle databases running on MC/SG with no problem at all. I was once configuring Omniback with SG, but then dropped the idea as we were moving to netbackup. There should be no problem with oracle integration with MC/SG. Have you spoken to hp support regarding this. They have a seperate team which tried to resolve all SG issues. Look for some of the team members names in the SG section. You'll find some of the posts from those team members. I remeber Stephen Doud to be one from that team.

Hope this helps.

Regds
Sanjay_6
Honored Contributor

Re: How to get and set a signal mask within an unix script.

Hi Rui,

forgot to mention one thing. When you post a question in the forum, do make sure you are using the right sub category. I feel this question of yours should have been posted in the SG category and not in general.

Thanks & Regards
Rui Vilao
Regular Advisor

Re: How to get and set a signal mask within an unix script.

Sanjay,

I have already opened a call to HP with this problem...

But I am trying to find out a turnaround solution..

If a given signal is masked by and application any child process will never catch it (smon is never getting a signal to accomplish oracle shutdown).

My question is how to check and reset this mask so that the applications started within my script work correctly...

TIA,

Kind Regards,

Rui.
"We should never stop learning"_________ rui.vilao@rocketmail.com
Sanjay_6
Honored Contributor

Re: How to get and set a signal mask within an unix script.

Hi Rui,

From what i understand, you are able to start the database with the SG script, but unable to shutdown the same. You can try this, do remember that the package will be failed over, if you are monitoring the oracle processes.

Start the package, let the database start with that. Login into the system as oracle and do a database shutdown manually using svrmgrl. If this works fine, you should be able to shutdown the database using the package shutdown script also. Can you post your control script and the dbstart and dbshut scripts for us to look at.

Hope this helps.

Regds
Rui Vilao
Regular Advisor

Re: How to get and set a signal mask within an unix script.

Sanjay,

Oracle is monitoring is not activated yet.

Outside my control.sh script, Oracle shutdown works (as user oracle..)...

Within the script it hangs!

Within my control script I do:

...
/etc/cmcluster/pkg_sys_db/mon_dbs.sh shutdown
...

"We should never stop learning"_________ rui.vilao@rocketmail.com
Sanjay_6
Honored Contributor

Re: How to get and set a signal mask within an unix script.

Hi Rui,

Use "su - oracle -c ...." inplace of "su oracle -c ...." in your control file and try.

Hope this helps.

Regds
Rui Vilao
Regular Advisor

Re: How to get and set a signal mask within an unix script.

Already tried something similar ... dos not work...

Note: with su -, I am not able to pass ORACLE_SID to my script...
I tried to put dbshut (which reads the SID in oratab)... and it hangs...

Thanks,

Rui.
"We should never stop learning"_________ rui.vilao@rocketmail.com
Bill Hassell
Honored Contributor

Re: How to get and set a signal mask within an unix script.

There is no global signal mask (like umask) for specific signals. In a script, you can choose to how to handle a signal such as SIGHUP, SIGQUIT, or SIGTERM by using the trap statement. The action specified by trap will be taken upon detection of the named signals, something like this:

trap "echo trap 2 or 3 seen" 2 3

So every time signals 1 2 or 3 (also known as kill signals) are sent to this script, it will just echo the message and continue on. Here's a sample script:

#!/usr/bin/sh
trap "echo Trap 2 3 or 15 seen" 2 3 15
while :
do
sleep 1
done

Run the script and from another session, issue kill commands -2 -3 or -15 and you'll see the program detect them. Use kill -1 to terminal the script (CTRL-C won't work as it is kill -15)

As for Oracle ignoring the signal(s), IF the signal was sent to an Oracle process, then the process is ignoring the signal and would have to be rewritten and recompiled to fix the problem. If the signal is being sent to a parent process, same requirement.

If the parent process is a shell script, make sure the script is using trap correctly. If no traps are in the script, does the script get started as an su login? Aha! Is the logfile full of login junk like the copyright message? This means that /etc/profile and .profile need some work.

Start by looking at /etc/profile: is there a trap command? If yes, is there a second? HP standard /etc/profile has two and they MUST exist in a pair:

trap "" 1 2 3

trap 1 2 3

If the second trap is missing (some sysadmins remove because it looks redundant) then subsequent activities spawned by the login shell will no longer respond to traps 1 2 or 3. The first statement: trap "" 1 2 3 means: do nothing if these traps are seen. The second statement: trap 1 2 3 will reanable standard behavior.

So make sure that all traps starting at the highest level are set and reset as required.

BTW: To fix all that extra login junk (including "not a typewriter' error messages, any command in a script that is interactive or terminal-based must be skipped when there is no terminal (such as cron jobs or start/stop scripts). The usual suspects are: tabs ttytype tput and of course: cat /etc/copyright.
In /etc/profile (and .profile if needed), test for interactive with:

if [ -o interactive ]
then
...do things like tput or tabs or cat /etc/copyright
fi

Now the interactive commands will only be run when there is a true interactive terminal in control of the session.


Bill Hassell, sysadmin
Sanjay_6
Honored Contributor

Re: How to get and set a signal mask within an unix script.

Hi Rui,

Try to call a script using su - oracle -c "ora_shutdown_script" and customize this script to passon the Oracle SID value to the shutdown program. We have multiple oracle datbases on same system with SG and we haev customised the dbshut script shutdown all the datbases. We just have to call this dhshut script from the SG control script.

Use the same steps in dbshut that you are using in control script for SG to shutdown the two datbases. Do a export of ORA_SID one by one and then do a shutdown for individual databases.

Why don't you try the whole operation with a single database and once you are successful with shutting down a single database with SG control script, you'll have some less steps to worry about. don't try to manipulate all the datbases at the same time. Take one at a time.

Hope this helps.

Regds
Rui Vilao
Regular Advisor

Re: How to get and set a signal mask within an unix script.

Hi,

First of all thanks to all who tried to help me in the solution of this problem...


I got the final solution from the HP support. Just for the record, here is it:

1. create program to set a new mask:

#include
#include

main(int argc, char **argv)
{
sigsetmask(0L);
execvp(argv[1], &argv[1]);
perror("execvp");
}

and call OV/oracle with it:
/dir/.../nome_pgm $OV_BIN/ovstart

2. Apply patch: PHSS_24537

Note: the patch solved the problem.


Regards & many thanks,

Rui.

"We should never stop learning"_________ rui.vilao@rocketmail.com