Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <signal.h>
- int mode = 0;
- void funct1(int sig)
- {
- mode = 0;
- return;
- }
- void funct2(int sig)
- {
- mode = 1;
- return;
- }
- int main(void)
- {
- signal(SIGUSR1, funct1);
- signal(SIGUSR2, funct2);
- int pid = getpid();
- printf("%d\n", pid);
- fflush(stdout);
- int a;
- while (scanf("%d", &a) > 0)
- {
- if(!mode)
- {
- printf("%d\n", -a);
- fflush(stdout);
- }
- else
- {
- printf("%d\n", a*a);
- fflush(stdout);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement