Annotation of src/usr.bin/ssh/check-fds.c, Revision 1.1
1.1 ! deraadt 1: /*
! 2:
! 3: check-fds.c
! 4:
! 5: Author: Tatu Ylonen <ylo@cs.hut.fi>
! 6:
! 7: Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
! 8: All rights reserved
! 9:
! 10: Created: Sat Apr 8 00:25:04 1995 ylo
! 11:
! 12: */
! 13:
! 14: #include <stdio.h>
! 15: RCSID("$Id: check-fds.c,v 1.2 1999/05/04 11:58:34 bg Exp $");
! 16:
! 17: #include <sys/types.h>
! 18: #include <fcntl.h>
! 19: #include <sys/stat.h>
! 20:
! 21: int main(int ac, char **av)
! 22: {
! 23: int i, dummy;
! 24: struct stat st;
! 25:
! 26: for (i = 0; i < 1024; i++)
! 27: if (fcntl(i, F_GETFL, &dummy) >= 0)
! 28: {
! 29: printf("Descriptor %d is open.\n", i);
! 30: if (fstat(i, &st) < 0)
! 31: perror("fstat");
! 32: else
! 33: {
! 34: printf("st_mode 0x%x, st_dev 0x%x, st_rdev 0x%x, st_ino 0x%x, st_size 0x%lx\n",
! 35: st.st_mode, st.st_dev, st.st_rdev, st.st_ino,
! 36: (long)st.st_size);
! 37: if (ttyname(i))
! 38: printf("ttyname: %.100s\n", ttyname(i));
! 39: }
! 40: }
! 41: exit(0);
! 42: }
! 43: