1 /* dtable.h: fd table definition.
3 Copyright 2000, 2001 Red Hat, Inc.
5 This file is part of Cygwin.
7 This software is a copyrighted work licensed under the terms of the
8 Cygwin license. Please consult the file "CYGWIN_LICENSE" for
11 /* Initial and increment values for cygwin's fd table */
12 #define NOFILE_INCR 32
19 fhandler_base **fds_on_hold;
20 int first_fd_for_open;
21 int cnt_need_fixup_before;
26 dtable () : first_fd_for_open(3), cnt_need_fixup_before(0), console_fds(0) {}
27 void init () {first_fd_for_open = 3;}
29 void dec_need_fixup_before ()
30 { if (cnt_need_fixup_before > 0) --cnt_need_fixup_before; }
31 void inc_need_fixup_before ()
32 { cnt_need_fixup_before++; }
33 BOOL need_fixup_before ()
34 { return cnt_need_fixup_before > 0; }
36 void dec_console_fds ();
37 void inc_console_fds ()
39 BOOL has_console_fds ()
40 { return console_fds > 0; }
42 int vfork_child_dup ();
43 void vfork_parent_restore ();
44 void vfork_child_fixup ();
45 fhandler_base *dup_worker (fhandler_base *oldfh);
46 int extend (int howmuch);
47 void fixup_before_exec (DWORD win_proc_id);
48 void fixup_before_fork (DWORD win_proc_id);
49 void fixup_after_fork (HANDLE);
50 fhandler_base *build_fhandler (int fd, DWORD dev, const char *name,
52 fhandler_base *build_fhandler (int fd, const char *name, HANDLE h = NULL,
53 path_conv *pc = NULL);
54 inline int not_open (int fd)
56 SetResourceLock (LOCK_FD_LIST, READ_LOCK, "not_open");
58 int res = fd < 0 || fd >= (int) size || fds[fd] == NULL;
60 ReleaseResourceLock (LOCK_FD_LIST, READ_LOCK, "not open");
63 int find_unused_handle (int start);
64 int find_unused_handle () { return find_unused_handle (first_fd_for_open);}
65 void release (int fd);
66 void init_std_file_from_handle (int fd, HANDLE handle, DWORD access, const char *name);
67 int dup2 (int oldfd, int newfd);
68 void fixup_after_exec (HANDLE);
69 inline fhandler_base *operator [](int fd) const { return fds[fd]; }
70 select_record *select_read (int fd, select_record *s);
71 select_record *select_write (int fd, select_record *s);
72 select_record *select_except (int fd, select_record *s);
73 operator fhandler_base **() {return fds;}
76 void dtable_init (void);
77 void stdio_init (void);
80 extern "C" int getfdtabsize ();
81 extern "C" void setfdtabsize (int);