i-bash/CWRU/misc/open-files.c

40 lines
1.1 KiB
C
Raw Normal View History

2002-07-17 14:10:11 +00:00
/* open-files -- report files a process has open */
2009-01-12 13:36:28 +00:00
/* Copyright (C) 1989-2009 Free Software Foundation, Inc.
2002-07-17 14:10:11 +00:00
This file is part of GNU Bash, the Bourne Again SHell.
2009-01-12 13:36:28 +00:00
Bash is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
2002-07-17 14:10:11 +00:00
2009-01-12 13:36:28 +00:00
Bash is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
2002-07-17 14:10:11 +00:00
2009-01-12 13:36:28 +00:00
You should have received a copy of the GNU General Public License
along with Bash. If not, see <http://www.gnu.org/licenses/>.
*/
2002-07-17 14:10:11 +00:00
1996-08-26 18:22:31 +00:00
#include <sys/types.h>
#include <fcntl.h>
#include <sys/file.h>
2006-10-10 14:15:34 +00:00
#include <unistd.h>
#include <stdlib.h>
1996-08-26 18:22:31 +00:00
#include <stdio.h>
main()
{
register int i;
for (i = 0; i < getdtablesize(); i++) {
if (fcntl(i, F_GETFD, 0) != -1)
fprintf(stderr, "fd %d: open\n", i);
}
exit(0);
}