Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <dirent.h>
- #include <sys/types.h>
- #include <sys/param.h>
- #include <unistd.h>
- #include <stdio.h>
- #include <string.h>
- #include <time.h>
- #include <sys/wait.h>
- #include <sys/signal.h>
- void child_proc_1_handler(int signum, siginfo_t *info, void *f) {
- if (info->si_code == SI_QUEUE)
- {
- printf("3 \n");
- printf("Number of elements:%lu \n", sizeof(info->si_value));
- }
- printf("4");
- return;
- }
- int main(int argc, const char **argv)
- {
- if (argc != 2)
- {
- printf("Not enough arguments... \n");
- exit(EXIT_FAILURE);
- }
- char *str = argv[1];
- struct sigaction act;
- memset(&act, 0, sizeof(act));
- act.sa_sigaction = child_proc_1_handler;
- sigemptyset(&act.sa_mask);
- sigaddset(&act.sa_mask, SIGUSR1);
- act.sa_flags = SA_SIGINFO;
- pid_t child_proc_1 = fork();
- if(child_proc_1 > 0)
- {
- union sigval value;
- int status;
- value.sival_ptr = str;
- printf("1 \n");
- sigqueue(child_proc_1,SIGUSR1,value);
- printf("2 \n");
- wait(&status);
- printf("6 \n");
- }
- else if (child_proc_1 == 0)
- {
- sigaction(SIGUSR1,&act,NULL);
- printf("5 \n");
- exit(333);
- }
- else
- {
- printf("Loshara");
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment