My Tech notes: Sending Data Other Process Signals

Unix Documentation

Free Online Unix Training Materials

Lists many links to free Unix training materials.

Pointers and Arrays Materials

Pointers and Arrays materials Explained for C beginners

C FAQ and General Questions C Interview Questions

Powered By

Free XML Skins for Blogger

Powered by Blogger

Wednesday, July 30, 2008

Sending Data Other Process Signals

Sending Signals With payload.
1) we can send signal from one process to other along with data.
2) Data can be an int or pointer to some location.
3) For pointer both process should have access to that location, In case of integer,
data is part of the signal.
4) There is no provision to include the payload in signal which is sent from kernel.
file: first.c
void sighandler(int sig, siginfo_t *info, void *arg)
printf("In Handler value %d\n", info->si_value.sival_int);
struct sigaction sa;
int ret;
sa.sa_sigaction = sighandler;
sa.sa_flags = SA_RESTART | SA_SIGINFO;
if((sigaction(SIGUSR1, &sa, NULL)) == -1) {
printf("Can't register handler\n");
for(;;) {
file second.c
main(int argc, char *argv[])
sigval_t value;
int ret, pid;
if(argc < 2) {
printf("%s \n", argv[0]);
pid = atoi(argv[1]);
value.sival_int = atoi(argv[2]);
ret = sigqueue(pid, SIGUSR1, value);
if(ret) {

No comments:

Post a Comment