1 #include <sys/types.h> 2 #include <sys/stat.h> 3 #include <fcntl.h> 4 #include <errno.h> 5 #include <unistd.h> 6 7 int main(void) 8 { 9 char buf[64]; 10 int fd; 11 12 fd = open("/proc/self/wchan", O_RDONLY); 13 if (fd == -1) { 14 if (errno == ENOENT) 15 return 2; 16 return 1; 17 } 18 19 buf[0] = '\0'; 20 if (read(fd, buf, sizeof(buf)) != 1) 21 return 1; 22 if (buf[0] != '0') 23 return 1; 24 return 0; 25 } 26