LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris
User Name
Password
Solaris / OpenSolaris This forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome.

Notices


Reply
  Search this Thread
Old 04-19-2005, 05:36 AM   #1
mrnuttynuts
LQ Newbie
 
Registered: Apr 2005
Posts: 1

Rep: Reputation: 0
Trapping Interrupt From 'ulimit' - SIGXCPU


I want to know the interrupt passed to a process through 'ulimit'

I am running a process which gets killed when the 'ulimit -t' reaches.
But after killing the process I want to start another process which would
send a message or do some clean up or anything at all.

To do the same I am using 'trap' and a function call, which does, rest of the
activity (mailing, cleanup, etc). But the problem is using the interrupt signal for trap.

I have tried using all from 1 to 38 which are mentioned in the "/usr/include/sys/iso/signal_iso.h" file.
But those signals are not what 'ulimit' sends to kill a running process on the system.
On the other hand what i observed was if "0" is used with trap, then the ulimit interrupt
is trapped and I am able to run the over head function in trap. But using 0 does not make
sense. And i have also not found any reference for the same mentioned anywhere.

In addition to the same. I tried using 'truss' to give me information as to which interrupt
is sent to my running process and truss shows that it is "/2: Received signal #30, SIGXCPU [default]"
But if i use 'trap' with 30 .. it still does not help.

Any ideas as to what kind of interrrupt does 'ulimit' send to a process and how can one trap the same.

To give u a sample of the code I am using. Please refer to the following example.

#!/bin/ksh

trapme(){
echo "stoppid me"
touch haha.$$
}

callmain(){

trap 'trapme' 30
truss find ./ -name "*signal*" | grep "_iso" | grep ".h" 1> tempout.$$ 2> temperr1.$$
}

callmain



I had posted this on some other forums as well. Would like to know what people out here think. I had recieved some replies for this and based on which I have done the following.

Okie I have gone forward and done some more research on the same.
Your idea of using C shell is very true and it works. But I guess I won't be able to use the same.

As long as the signal getting passed to korn shell is concerned here is my analysis.

If i use the following script,

==================================================
#!/bin/ksh

ulimit -t 1

trap 'echo "CPU time limit exceeded"; exit 2' XCPU
num=1
while true
do
echo $num >> haha
num=`expr $num + 1`
done


Output:
asakpal[/export/home/asakpal] ksh r.sh
CPU time limit exceeded
asakpal[/export/home/asakpal] echo $?
2
asakpal[/export/home/asakpal]

==================================================

then the trap works fine and it does what it's supposed to do.
Basically this argument refutes the fact that
"But ksh does not make all signals available to the script for direct manipulation."

But on the other hand if i use this following script.

==================================================
#!/bin/ksh

ulimit -t 1

trap 'echo "CPU time limit exceeded"; exit 2' XCPU

find / -name "*haha*" 2> /dev/null


Output:
asakpal[/export/home/asakpal] ksh f.sh
f.sh[17]: 13404 Cpu Limit Exceeded
asakpal[/export/home/asakpal] echo $?
158
asakpal[/export/home/asakpal]


==================================================

then I get a core dumped error. But I still do not get a my echo message.


What baffles me is that for one type of execution trap works while for other it doesn't. Any more ideas
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
trapping packets mohit_garg Linux - Networking 6 07-10-2005 05:29 PM
<0>Kernel panic: Aiee, killing interrupt handler! In interrupt handler - not syncing mrb Linux - Newbie 2 01-09-2005 09:47 AM
Trapping NFS requests Jayendra Linux - Networking 0 03-01-2004 09:17 AM
Trapping an exit status chrisk5527 Linux - General 3 09-12-2003 09:02 PM
Trapping keystrokes in C k4zau Programming 3 03-09-2003 01:13 PM

LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris

All times are GMT -5. The time now is 12:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration