#include #include #include #include #include #include void checkIsSocket(int fd) { struct stat buf; memset(&buf, 0, sizeof (buf)); if (fstat(fd, &buf) < 0) { syslog(LOG_INFO, "fstat() failed with %d\n", errno); return; } if (S_ISSOCK(buf.st_mode)) { syslog(LOG_INFO, "fd %d is a socket\n", fd); } else { syslog(LOG_INFO, "fd %d is not a socket\n", fd); } } int main() { checkIsSocket(0); checkIsSocket(1); checkIsSocket(2); char buf[1024]; if (NULL == fgets(buf, 1024, stdin)) { syslog(LOG_INFO, "stdin %s", strerror(errno)); } if (EOF == fputs("yo", stdout)) { syslog(LOG_INFO, "stdout %s", strerror(errno)); } else { if (EOF == fflush(stdout)) { syslog(LOG_INFO, "stdout flush %s", strerror(errno)); } } if (EOF == fputs("yo", stderr)) { syslog(LOG_INFO, "stderr %s", strerror(errno)); } else { if (EOF == fflush(stderr)) { syslog(LOG_INFO, "stderr flush %s", strerror(errno)); } } }