Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1 | #include <fcntl.h> |
| 2 | #include <stdio.h> |
| 3 | main(int argc, char *argv[]) |
| 4 | { |
| 5 | int pid = atoi(argv[1]); |
| 6 | int sfd; |
| 7 | char sname[32]; |
| 8 | char buf[1024]; |
| 9 | char *s; |
| 10 | int i; |
| 11 | int signal, blocked, ignore, caught; |
| 12 | |
| 13 | sprintf(sname, "/proc/%d/stat", pid); |
| 14 | if ((sfd = open(sname, O_RDONLY)) == -1) { |
| 15 | perror(sname); |
| 16 | return 1; |
| 17 | } |
| 18 | i = read(sfd, buf, 1024); |
| 19 | buf[i] = '\0'; |
| 20 | for (i = 0, s = buf; i < 30; i++) { |
| 21 | while (*++s != ' ') { |
| 22 | if (!*s) |
| 23 | break; |
| 24 | } |
| 25 | } |
| 26 | if (sscanf(s, "%d%d%d%d", &signal, &blocked, &ignore, &caught) != 4) { |
| 27 | fprintf(stderr, "/proc/pid/stat format error\n"); |
| 28 | return 1; |
| 29 | } |
| 30 | printf("%8x %8x %8x %8x\n", signal, blocked, ignore, caught); |
| 31 | return 1; |
| 32 | } |