TrickmanOff

caos_signals_1

Mar 10th, 2022
575
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.40 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <unistd.h>
  3. #include <stdlib.h>
  4. #include <sys/types.h>
  5.  
  6. int main(int argc, char *argv[]) {
  7.     if (argc != 2) {
  8.         printf("usage: ./sleepread DELAY\n");
  9.         return 1;
  10.     }
  11.  
  12.     int delay = atoi(argv[1]);
  13.     printf("started with pid %d\n", getpid());
  14.     sleep(delay);
  15.     printf("trying to read\n");
  16.  
  17.     char c = getchar();
  18.     printf("read %c\n", c);
  19. }
Advertisement
Add Comment
Please, Sign In to add comment