Hello! I have recently began to program in UNIX environments and I am currently reading about signals.So i tried a snippet that seems it doesn't do what i intended to.So i want to print the counter i from a for loop until a value is reached, than stop the process.Instead i get the process killed without any output.
1 #include <stdio.h>
2 #include <sys/types.h>
3 #include <unistd.h>
4 #include <signal.h>
5
6 int main()
7 {
8 pid_t my_pid;
9
10 my_pid=getpid();
11
12 int i;
13 for (i=0;i<30;i++)
14 {
15
16 fprintf(stdout,"%d ",i);
17 if (i==20)
18 kill(my_pid,SIGSTOP);
19 }
20
21 return 0;
22 }
Any help is more then welcome.Thank you.