Sponsored Content
Full Discussion: signals related question
Top Forums Programming signals related question Post 302106912 by matrixmadhan on Tuesday 13th of February 2007 07:13:47 AM
Old 02-13-2007
Quote:
I know that if an application is in the sleep state, When a signal is catched, it will be processed by the handler. But what happens if it's processing something?
Not so, really Smilie

take this example program

Code:
#include <stdio.h>
#include <signal.h>

void process(void);
void sigFunc(int);

void sigFunc(int sigNo) {
  printf("Received Signal: %d\n", sigNo);
  exit (1);
}

void process() {
  //Run it with printf uncommented and sleep commented
  //For the second time do the vice-versa

  //printf("What am I doing\n");
  sleep(1);
}

int main()
{
  signal(SIGUSR1, sigFunc);
  while (1) {
    process();
  }
  return 0;
}


If you do run the program in two different ways, where printf is active, therefore its processing
and in the second form where it is in sleep mode, thereby after executing the sleep call

in either of the case, whatever be the state of the program that is in memory when kernel delivers a signal to the process,
if the signal handler is registered with a function 'f' it would be executed else default action of the delivered signal would be executed.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

A Question related to the net

well, I was suggested to remove the contents of the cache as i get out of the browser netscape from the .netscape folder. is that really necessary? if so what are the rest to be done? can anybody please tell me?:rolleyes: (8 Replies)
Discussion started by: sskb
8 Replies

2. Programming

Unix/Linux Newbie(ish) Question - IPC/Signals

:) Hello, i have been given the following code to help me learn how to use signals, it won't compile. The problem maybe because this was written for use in Unix and i am trying to compile in Linux. The error i get says that SIGPIPE and SIG_IGN are undeclared. I think that these are defined... (2 Replies)
Discussion started by: theultimatechuf
2 Replies

3. UNIX for Advanced & Expert Users

One Question related to alias

Hello, I have created following alias in csh lab 'rlogin -l user23 complab23' but problem is complab23 does not allow automatic login by checking .rhosts file. So after typing lab on command line I have to type complicate password and if wrong password is typed thrice then account gets... (4 Replies)
Discussion started by: neerajrathi2
4 Replies

4. Shell Programming and Scripting

Question using signals in my own shell..

Wasn't really sure where to put this, since I'm using C in UNIX, but I am making my own shell... so, what's going on is this: For our program, we had to create our own shell, and if the user pressed ctrl-c just at the cmdline, then this signal would be ignored, but if there is a foreground... (1 Reply)
Discussion started by: blind melon
1 Replies

5. Shell Programming and Scripting

A question about signals in Unix

Whats a signal 0. An exhaustive search on signals landed me nowhere. Is it possible to do something like this trap "echo $var" 0. If so what signal does this trap catch ? (2 Replies)
Discussion started by: kinny
2 Replies

6. Shell Programming and Scripting

awk related question

awk "/^<Mar 31, 2012 : /,0" /app/blah.log can someone please help me figure out why the above command isn't pulling anything out from the log? basically, i want it to pull out all records, from the very first line that starts with the date "Mar 31, 2012" and that also has a time immediately... (4 Replies)
Discussion started by: SkySmart
4 Replies

7. Shell Programming and Scripting

Perl related question

hi, iam perl begginer,i have written the program #!/usr/bin/perl #use warnings; use strict; print "Enter the name:","\n"; my $name=<STDIN>; my %hash=(siva => "9902774481", dev => "9916391244", venky => "9440506760", manohar => "9440232695" ); print "$name no is:... (5 Replies)
Discussion started by: siva.hardwork
5 Replies

8. UNIX for Dummies Questions & Answers

Question related to 'ps'

If I run a script called 'abc.sh' and then execute the following : ps -ef | grep 'abc.sh' I always get two rows of output, one for the executing script, and the other for the grep command that I have triggered after the pipe. Questions: Why does the second row turn up in the results. My... (10 Replies)
Discussion started by: jawsnnn
10 Replies

9. Shell Programming and Scripting

awk related question

awk -F ";" 'FNR==NR{a=$1;next} ($2 in a)' server.list datafile | while read line do echo ${line} done when i run the above, i get this: 1 SERVICE NOTIFICATION: nagiosadmin skysmart-01.sky.net .... instead of: SERVICE NOTIFICATION: nagiosadmin skysmart-01.sky.net .... can... (4 Replies)
Discussion started by: SkySmart
4 Replies

10. UNIX for Dummies Questions & Answers

Question related to grep

We have huge file with control A as delimiter. Somehow one record is corrupted. This time i figured it out using ETL graph. If future , how to print only bad record. Example Correct record:... (2 Replies)
Discussion started by: srikanth38
2 Replies
sigpending(2)							System Calls Manual						     sigpending(2)

NAME
sigpending - examine pending signals SYNOPSIS
DESCRIPTION
stores the set of signals that are blocked from delivery and are pending to the calling thread, at the location pointed to by set. RETURN VALUE
Upon successful completion, returns 0. Otherwise -1 is returned and is set to indicate the error. ERRORS
fails if the following condition is encountered: set points to an invalid address. The reliable detection of this error is implementation-dependent. APPLICATION USAGE
Threads Considerations The set of signals returned by is the union of the signals pending on the process and calling thread. A signal may be pending on the process if all threads block the signal. The set of signals returned by is only advisory. Since other threads may be executing at the time of the call, a signal pending on the process may be delivered to a thread after this system call returns. For more information regarding signals and threads, refer to signal(5). LWP (Lightweight Processes) Considerations The set of signals returned by is the union of the signals pending on the process and calling LWP. AUTHOR
was derived from the IEEE POSIX 1003.1-1988 Standard. SEE ALSO
sigaction(2), sigsuspend(2), sigprocmask(2), sigsetops(3C), signal(5). CHANGE HISTORY
First release in Issue 3. STANDARDS CONFORMANCE
: AES, SVID3, XPG3, XPG4, FIPS 151-2, POSIX.1 sigpending(2)
All times are GMT -4. The time now is 01:36 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy