The Open Source Swiss Army Knife

/code/c/unix_c/signals/
/code/c/unix_c/signals/ + sub-categories
http://www.sirfsup.com/
web directory content
    
      

Not logged in
Chat Register Login
return to:  http:/www.sirfsup.com      /code   /c   /unix_c   /signals 
Permalink: sendsigqueue.c
Title: add
article options : please login   |  raw source view  

/* http://vip.cs.utsa.edu/usp/  dr.robbins utsa computer science  "unix systems programming" */
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {
   int pid;
   int signo;
   int sval;
   union sigval value;

   if (argc != 4) {
      fprintf(stderr, "Usage: %s pid signal value\n", argv[0]);
      return 1; 
   }
   pid = atoi(argv[1]);
   signo = atoi(argv[2]);
   sval = atoi(argv[3]);
   fprintf(stderr, "Sending signal %d with value %d to process %d\n",
                    signo, sval, pid);
   value.sival_int = sval;
   if (sigqueue(pid, signo, value) == -1) {
      perror("Failed to send the signal");
      return 1;
   }
   return 0;
}

Leave a Reply
Your Name:     anonymous
Your Email:
Website:  
Comments:

The author will be notified of your reply.
return to top