Sponsored Content
Full Discussion: Trying to block signal
Top Forums UNIX for Dummies Questions & Answers Trying to block signal Post 302465435 by DGPickett on Friday 22nd of October 2010 11:53:51 AM
Old 10-22-2010
One of the stop signals cannot be caught, something the kill not signal man page tells you. My very educational buddy truss/tusc tells us:
Code:
tusc -fap ksh -i

(p is a named pipe, so typing 'wc p' hangs blocked on open, and the cntrl-z stops it) that ^Z stty susp is SIGTSTP, which can be caught. You were blocking that signal, not SIGINT = cntrl-c usually. Maybe you need to catch it but do little? Else, Google 'UNIX signal tutorial' like I do at such times. Smilie
Moderator's Comments:
Mod Comment Unix/Linux Man Pages are found here, on our site. Please use them in these forums.

Code:
 .
 .
 .
[532] read(0, 0x400059b0, 1024) .......................... [sleeping]
wc p
[532] read(0, "w c   p \n", 1024) ........................ = 5
 .
 .
 .
[532] fork() ............................................. = 536
[536] fork() .......... (returning as child ...) ......... = 532
 .
 .
 .
[536] execve(0x40056b32, 0x400564ac, 0x4005677c) ......... [entry]
                              argv[0] @ 0x4005647d: "wc"
                              argv[1] @ 0x4005649d: "p"
[536] execve("/usr/bin/wc", 0x400564ac, 0x4005677c) ...... = 0 [32-bit]
 .
 .
 .
[536] open(0x7b0f0003, O_RDONLY|O_LARGEFILE, 0666) ....... [sleeping]
(^Z)
[532] waitpid(-1, WIFSTOPPED(SIGTSTP), WUNTRACED) ........ = 536
[532] sigvec(SIGCLD, 0x7b118258, 0x7b118268) ............. = 0
[532] waitpid(-1, WIFSTOPPED(SIGTSTP), WNOHANG|WUNTRACED)  = 0
[532] sigvec(SIGCLD, 0x7b118258, 0x7b118268) ............. = 0
[532] sigvec(SIGCLD, 0x7b118198, 0x7b1181a8) ............. = 0
[532] ioctl(2, TIOCGPGRP, 0x7b1181d0) .................... = 0
[532] ioctl(2, TIOCSPGRP, 0x7b118198) .................... = 0
[532] ioctl(2, TCSETATTRF, 0x40004e80) ................... = 0
[532] sigprocmask(SIG_BLOCK, 0x7b1180f0, 0x7b1180d0) ..... = 0
[532] sigprocmask(SIG_SETMASK, 0x7b1180d0, NULL) ......... = 0
[532] sigvec(SIGCLD, 0x7b117d98, 0x7b117da8) ............. = 0
[532] waitpid(-1, WIFSTOPPED(SIGTSTP), WNOHANG|WUNTRACED)  = 0
[532] sigvec(SIGCLD, 0x7b117d98, 0x7b117da8) ............. = 0
[532] lseek(2047, 864312, SEEK_SET) ...................... = 864312
[532] sigprocmask(SIG_BLOCK, 0x7b117f30, 0x7b117f10) ..... = 0
[532] read(2047, "w c   p \n\0", 1024) ................... = 6
[532] sigprocmask(SIG_SETMASK, 0x7b117f10, NULL) ......... = 0
[532] time(0x7b117c50) ................................... = 1287760639
[532] lseek(2047, 864318, SEEK_SET) ...................... = 864318
[532] sigprocmask(SIG_BLOCK, 0x7b117db0, 0x7b117d90) ..... = 0
[532] read(2047, 0x40055c98, 1024) ....................... = 0
[532] sigprocmask(SIG_SETMASK, 0x7b117d90, NULL) ......... = 0
[532] ioctl(0, TIOCGWINSZ, 0x7b117d10) ................... = 0
[1] + Stopped                  wc p
$ [532] write(2, "[ 1 ]   +   S t o p p e d       ".., 38) . = 38
[532] sigvec(SIGCLD, 0x7b117ed8, 0x7b117ee8) ............. = 0
[532] waitpid(-1, WIFSTOPPED(SIGTSTP), WNOHANG|WUNTRACED)  = 0
[532] sigvec(SIGCLD, 0x7b117ed8, 0x7b117ee8) ............. = 0
[532] sigprocmask(SIG_BLOCK, 0x7b117db0, 0x7b117d90) ..... = 0
[532] read(0, 0x400059b0, 1024) .......................... [sleeping]

Code:
$ stty -a
speed 9600 baud; line = 0; 
rows = 25; columns = 80
min = 4; time = 0; 
intr = ^C; quit = ^\; erase = ^H; kill = ^U
eof = ^D; eol = ^@; eol2 <undef>; swtch = ^@
stop = ^S; start = ^Q; susp = ^Z; dsusp <undef>
werase <undef>; lnext <undef>
-parenb -parodd cs8 -cstopb hupcl cread -clocal -loblk -crts 
-ignbrk brkint ignpar -parmrk -inpck istrip -inlcr -igncr icrnl -iuclc 
ixon ixany ixoff -imaxbel -rtsxoff -ctsxon -ienqak 
isig icanon -iexten -xcase echo echoe echok -echonl -noflsh 
-echoctl -echoprt -echoke -flusho -pendin 
opost -olcuc onlcr -ocrnl -onocr -onlret -ofill -ofdel -tostop 
$



---------- Post updated at 11:53 AM ---------- Previous update was at 11:49 AM ----------




PS:

Introduction To Unix Signals Programming

Note: Older systems do not support the sigprocmask() system call. Instead, one should use the sigmask() and sigsetmask() system calls. If you have such an operating system handy, please read the manual pages for these system calls. They are simpler to use than sigprocmask, so it shouldn't be too hard understanding them once you've read this section.
These 2 Users Gave Thanks to DGPickett For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Alarm signal

Hi, when I execute a script on unix AIX, I've got an error message: "Execution: 85328 Signal d'alarme". If I edit this file with "vi", I ve got the same error after a while (about 1 minute). If I try with another user I still have the problem. But if I rename this file, no problem. My... (5 Replies)
Discussion started by: cgsteph
5 Replies

2. Programming

Signal Names

Hi everyone, Is there a variable or built in function in the Unix env. for me to obtain the name of a signal that is caught? As far as I understand only a numeric value of the signal is returned to the handler. For example: void handler (int signum) { ... (2 Replies)
Discussion started by: laila63
2 Replies

3. UNIX for Advanced & Expert Users

kill signal

Hello e'bdy, We have WebSphere MQ running on AIX 5.1 Every weekend MQ receives a kill -30 signal from some process or user and offloads a big error file. There is no way in MQ through which that process can be tracked. Is there something which i can do on UNIX level to trap the process? Best... (3 Replies)
Discussion started by: jhaavinash
3 Replies

4. UNIX for Advanced & Expert Users

Kill Signal

Hello, I'm doing a project of OS simulation (Process Scheduling, to be very specific). Can anyone, please, explain what exactly happens in the background when we see "Sending all processes the KILL signal...........". How is it sent to each process? Is it that something like a boolean is stored... (3 Replies)
Discussion started by: ameya
3 Replies

5. Shell Programming and Scripting

Signal question

Who can explain the meaning of the &2 &1 or @, #, etc in the script? Is there any document which can explain the usage of these words in details? for example: ls /etc/sysconfig/network > /dev/null 2>&1 #@ bash, ksh and sh. Thanks in advance for ur advice. (1 Reply)
Discussion started by: GCTEII
1 Replies

6. Shell Programming and Scripting

signal script?

I have a script which invoke a java program, because the program requires file as input, hence the script would sleep a X seconds then check for file existence, if the file exists then program is invoker else, keep waiting until the time is up. My problem is that if there is a way to find out if my... (1 Reply)
Discussion started by: mpang_
1 Replies

7. Programming

Signal catching

Hi! I want to catch all signals that my program receives print their name and then execute the default handler. Can you help me on that? I've tried the following code: #include <stdio.h> #include <unistd.h> #include <signal.h> void (*hnd)(int i); char signals = { "SIGHUP",... (7 Replies)
Discussion started by: dark_knight
7 Replies

8. Shell Programming and Scripting

Killed by signal 15.

Hi all I have Master script, Main script ,and 4 Child script. Master.sh #!/bin/bash /export/home/user/Main.shMain.sh #!/bin/bash /export/home/user/Child1.sh & /export/home/user/Child2.sh & /export/home/user/Child3.sh & /export/home/user/Child4.sh &I run only Master.sh script... (1 Reply)
Discussion started by: almanto
1 Replies

9. Programming

queue a signal

A program have to receive signals and work agreed with it, but the process have to receive more than one signal when it is attending other. Those have to be queued to be attended later recived. how can i do that? thanks. (2 Replies)
Discussion started by: marmaster
2 Replies

10. Programming

Signal function

Hello I want to know how can i use signal function in c for keyboard interrupt handling. what i exactly want is : my program is processing and if i press any key while processing , the program should call the interrupt and displays/prints that key and now goes back to processing. I added the... (5 Replies)
Discussion started by: Jahanzeb
5 Replies
All times are GMT -4. The time now is 05:50 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy