blob: b5ff847a41a228d2f7a10386e5f744594bd0f2e0 [file] [log] [blame]
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001#include <fcntl.h>
2#include <stdio.h>
Denys Vlasenko8ed57272009-02-25 14:24:02 +00003
4int main(int argc, char *argv[])
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00005{
6 int pid = atoi(argv[1]);
7 int sfd;
8 char sname[32];
9 char buf[1024];
10 char *s;
11 int i;
12 int signal, blocked, ignore, caught;
13
14 sprintf(sname, "/proc/%d/stat", pid);
Denys Vlasenko8ed57272009-02-25 14:24:02 +000015
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000016 if ((sfd = open(sname, O_RDONLY)) == -1) {
17 perror(sname);
18 return 1;
19 }
Denys Vlasenko8ed57272009-02-25 14:24:02 +000020
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000021 i = read(sfd, buf, 1024);
22 buf[i] = '\0';
Denys Vlasenko8ed57272009-02-25 14:24:02 +000023
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000024 for (i = 0, s = buf; i < 30; i++) {
25 while (*++s != ' ') {
26 if (!*s)
27 break;
28 }
29 }
Denys Vlasenko8ed57272009-02-25 14:24:02 +000030
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000031 if (sscanf(s, "%d%d%d%d", &signal, &blocked, &ignore, &caught) != 4) {
32 fprintf(stderr, "/proc/pid/stat format error\n");
33 return 1;
34 }
Denys Vlasenko8ed57272009-02-25 14:24:02 +000035
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000036 printf("%8x %8x %8x %8x\n", signal, blocked, ignore, caught);
Denys Vlasenko8ed57272009-02-25 14:24:02 +000037
38 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000039}