f6936c48f3
* cygwin.din: Make clock SIGFE. Add clock_gettime, sigwaitinfo, timer_create, timer_delete, timer_settime. * include/cygwin/version.h: Reflect above additions. * fork.cc (fork_child): Call fixup_timers_after_fork. * signal.cc (sigwait): Remove unused variable. * timer.cc: New file. (clock_gettime): Define new function. (timer_tracker): Define new struct used by timer functions. (timer_tracker::timer_tracker): New function. (to_us): New function. (timer_thread): New function. (timer_tracker::settime): New function. (timer_create): New function. (timer_settime): New function. (timer_delete): New function. (fixup_timers_after_fork): New function. * cygthread.cc: Bump thread count. * signal.cc (sigwaitinfo): Define new function. (sigwait): Redefine based on sigwaitinfo. * include/cygwin/signal.h (sigwaitinfo): Declare. (sigwait): Ditto. * dtable.cc (dtable::vfork_parent_restore): Avoid double close of ctty when ctty == ctty_on_hold. * cygtls.h (_threadinfo::threadkill): New element. (_threadinfo::set_threadkill): Declare new function. (_threadinfo::reset_threadkill): Declare new function. * dcrt0.cc (dcrt0_1): Call here so that it will be possible to attach to running process with #(*& Windows Me/9x. (initial_env): Try to initialize strace if uninitialized. * gendef: Don't zero signal if threadkill is set since that will happen in the called function. * signal.cc (sigwait): Ensure cleanup in error conditions. * sigproc.cc (sig_send): Clear packet mask storage. (wait_subproc): Fill in child exit code in siginfo_t structure. * thread.cc (pthread_kill): Set threadkill flag. * tlsoffsets.h: Regenerate. Throughout, use siginfo_t to fill out all signal information for "kernel" signals. * cygtls.h (_threadinfo::set_siginfo): Declare new function. * cygtls.cc (_threadinfo::set_siginfo): Define new function. * dcrt0.cc (do_exit): Accommodate siginfo_t considerations. * exceptions.cc (handle_exceptions): Ditto. (sig_handle_tty_stop): Ditto. (ctrl_c_handler): Use killsys() to send signal. (sigpacket::process): Rename from sig_handle. Use siginfo_t field from sigpacket for everything. (tty_min::kill_pgrp): Accommodate siginfo_t considerations. (fhandler_termios::bg_check): Ditto. * fhandler_tty.cc (fhandler_tty_slave::ioctl): Use killsys() to send signal. * signal.cc (kill_worker): Rewrite to use siginfo_t second argument. (kill_pgrp): Ditto. (kill0): Define new function pulled from kill(). (kill): Rewrite as frontend to kill0. (killsys): Define new function. * sigproc.cc (sigelem): Eliminate. (sigpacket): Move to sigproc.h. Subsume sigelem. (pending_signals): Use sigpacket rather than sigelem for everything. (sig_clear): Ditto. (wait_sig): Ditto. (sig_send): Rewrite to use siginfo_t argument. (sig_send): New function wratpper to sig_send with siginfo_t argument. (wait_subproc): Accommodate siginfo_t considerations. * thread.cc (pthread_kill): Ditto. * sigproc.h (sigpacket): Move here. (sigpacket::process): Declare "new" function. (sig_handle): Eliminate declaration. (sig_send): Declare with new paramaters. (killsys): Declare new function. (kill_pgrp): Declare. * winsup.h: Move some signal-specific stuff to sigproc.h. * include/cygwin/signal.h: Tweak some siginfo_t stuff.
99 lines
3.0 KiB
C++
99 lines
3.0 KiB
C++
/* dtable.h: fd table definition.
|
|
|
|
Copyright 2000, 2001, 2003, 2004 Red Hat, Inc.
|
|
|
|
This file is part of Cygwin.
|
|
|
|
This software is a copyrighted work licensed under the terms of the
|
|
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
|
details. */
|
|
|
|
/* Initial and increment values for cygwin's fd table */
|
|
#define NOFILE_INCR 32
|
|
|
|
#include "thread.h"
|
|
#include "sync.h"
|
|
|
|
class suffix_info;
|
|
class fhandler_fifo;
|
|
|
|
#define BFH_OPTS (PC_NULLEMPTY | PC_FULL | PC_POSIX)
|
|
class dtable
|
|
{
|
|
muto *lock_cs;
|
|
fhandler_base **fds;
|
|
fhandler_base **fds_on_hold;
|
|
fhandler_base **archetypes;
|
|
unsigned narchetypes;
|
|
unsigned farchetype;
|
|
static const int initial_archetype_size = 8;
|
|
int first_fd_for_open;
|
|
int cnt_need_fixup_before;
|
|
void lock () {lock_cs->acquire ();}
|
|
void unlock () {lock_cs->release ();}
|
|
void init_lock ();
|
|
public:
|
|
size_t size;
|
|
|
|
dtable () : archetypes (NULL), narchetypes (0), farchetype (0), first_fd_for_open(3), cnt_need_fixup_before(0) {}
|
|
void init () {first_fd_for_open = 3;}
|
|
|
|
void dec_need_fixup_before ()
|
|
{ if (cnt_need_fixup_before > 0) --cnt_need_fixup_before; }
|
|
void inc_need_fixup_before ()
|
|
{ cnt_need_fixup_before++; }
|
|
bool need_fixup_before ()
|
|
{ return cnt_need_fixup_before > 0; }
|
|
|
|
int vfork_child_dup ();
|
|
void vfork_parent_restore ();
|
|
void vfork_child_fixup ();
|
|
fhandler_base *dup_worker (fhandler_base *oldfh);
|
|
int extend (int howmuch);
|
|
void fixup_before_exec (DWORD win_proc_id);
|
|
void fixup_before_fork (DWORD win_proc_id);
|
|
void fixup_after_fork (HANDLE);
|
|
inline int not_open (int fd)
|
|
{
|
|
lock ();
|
|
int res = fd < 0 || fd >= (int) size || fds[fd] == NULL;
|
|
unlock ();
|
|
return res;
|
|
}
|
|
int find_unused_handle (int start);
|
|
int find_unused_handle () { return find_unused_handle (first_fd_for_open);}
|
|
void release (int fd);
|
|
void init_std_file_from_handle (int fd, HANDLE handle);
|
|
int dup2 (int oldfd, int newfd);
|
|
void fixup_after_exec (HANDLE);
|
|
inline fhandler_base *&operator [](int fd) const { return fds[fd]; }
|
|
select_record *select_read (int fd, select_record *s);
|
|
select_record *select_write (int fd, select_record *s);
|
|
select_record *select_except (int fd, select_record *s);
|
|
operator fhandler_base **() {return fds;}
|
|
void stdio_init ();
|
|
void get_debugger_info ();
|
|
void set_file_pointers_for_exec ();
|
|
bool in_vfork_cleanup () {return fds_on_hold == fds;}
|
|
fhandler_fifo *find_fifo (ATOM);
|
|
fhandler_base *find_archetype (device& dev);
|
|
fhandler_base **add_archetype ();
|
|
void delete_archetype (fhandler_base *);
|
|
friend void dtable_init ();
|
|
friend void __stdcall close_all_files ();
|
|
friend class cygheap_fdmanip;
|
|
friend class cygheap_fdget;
|
|
friend class cygheap_fdnew;
|
|
};
|
|
|
|
fhandler_base *build_fh_dev (const device&, const char * = NULL);
|
|
fhandler_base *build_fh_name (const char *unix_name, HANDLE = NULL, unsigned = 0, suffix_info * = NULL);
|
|
fhandler_base *build_fh_pc (path_conv& pc);
|
|
|
|
void dtable_init (void);
|
|
void stdio_init (void);
|
|
extern dtable fdtab;
|
|
|
|
extern "C" int getfdtabsize ();
|
|
extern "C" void setfdtabsize (int);
|