2000-02-18 03:38:33 +08:00
|
|
|
/* exceptions.cc
|
|
|
|
|
2005-02-20 12:25:33 +08:00
|
|
|
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
|
2011-04-18 03:56:25 +08:00
|
|
|
2005, 2006, 2007, 2008, 2009, 2010, 2011 Red Hat, Inc.
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
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. */
|
|
|
|
|
2009-01-03 13:12:22 +08:00
|
|
|
#define CYGTLS_HANDLE
|
2000-08-03 00:28:18 +08:00
|
|
|
#include "winsup.h"
|
2008-04-08 00:15:45 +08:00
|
|
|
#include "miscfuncs.h"
|
* wininfo.h (wininfo::timer_active): Delete.
(wininfo::itv): Ditto.
(wininfo::start_time): Ditto.
(wininfo::window_started): Ditto.
(wininfo::getitimer): Ditto.
(wininfo::setitimer): Ditto.
(wininfo::wininfo): Ditto.
(wininfo::lock): New method.
(wininfo::release): Ditto.
* window.cc: Use new lock/acquire wininfo methods throughout.
(wininfo::wininfo): Delete
(wininfo::getitimer): Ditto.
(wininfo::setitimer): Ditto.
(getitimer): Ditto.
(setitimer): Ditto.
(ualarm): Ditto.
(alarm): Ditto.
(wininfo::lock): Define new function.
(wininfo::release): Ditto.
(wininfo::process): Delete WM_TIMER handling.
* timer.cc (struct timetracker): Delete it, flags. Add it_interval,
interval_us, sleepto_us, running, init_muto(), syncthread, and gettime().
(ttstart): Make NO_COPY.
(lock_timer_tracker): New class.
(timer_tracker::timer_tracker): Distinguish ttstart case.
(timer_tracker::~timer_tracker): New destructor. Clean out events, and reset
magic.
(timer_tracker::init_muto): New method.
(to_us): Round up as per POSIX.
(timer_thread): Reorganize to match timer_tracker::settime and
timer_tracker::gettime. Call sig_send without wait. Call auto_release.
(timer_tracker::settime): Reorganize logic to avoid race. Call gettime to
recover old value.
(timer_tracker::gettime): New method.
(timer_create): Properly set errno on invalid timerid. Use new
lock_timer_tracker method.
(timer_delete): Ditto. Simplify code slightly.
(timer_gettime): New function.
(fixup_timers_after_fork): Reinit ttstart.
(getitimer): New implementation.
(setitimer): Ditto.
(ualarm): Ditto.
(alarm): Ditto.
* cygwin.din: Export timer_gettime.
* winsup.h: Remove has has_visible_window_station declaration.
* Makefile.in (DLL_OFILES): Add lsearch.o.
* cygthread.h (cygthread::notify_detached): New element.
(cygthread::cygthread): Take optional fourth argument signifying event to
signal on thread completion.
* cygthread.cc (cygthread::stub): Signal notify_detached event, if it exists.
(cygthread::cygthread): Initialize notify_detached from fourth argument.
(cygthread::detach): Wait for notify_detached field is present.
* lsearch.cc: New file.
* search.h: Ditto.
* include/cygwin/version.h: Bump API minor number to 126.
* cygwin.din: Export lsearch, lfind.
2005-03-27 09:57:38 +08:00
|
|
|
#include <wingdi.h>
|
|
|
|
#include <winuser.h>
|
2000-08-22 13:10:20 +08:00
|
|
|
#include <imagehlp.h>
|
2001-11-15 11:25:52 +08:00
|
|
|
#include <stdlib.h>
|
2005-12-28 04:07:59 +08:00
|
|
|
#include <syslog.h>
|
2008-04-03 23:28:03 +08:00
|
|
|
#include <wchar.h>
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2000-08-12 13:35:42 +08:00
|
|
|
#include "pinfo.h"
|
2003-11-29 04:55:59 +08:00
|
|
|
#include "cygtls.h"
|
|
|
|
#include "sigproc.h"
|
2000-09-08 00:23:51 +08:00
|
|
|
#include "shared_info.h"
|
2000-09-08 10:56:55 +08:00
|
|
|
#include "perprocess.h"
|
2005-10-04 01:23:54 +08:00
|
|
|
#include "path.h"
|
|
|
|
#include "fhandler.h"
|
|
|
|
#include "dtable.h"
|
|
|
|
#include "cygheap.h"
|
2006-05-22 12:50:54 +08:00
|
|
|
#include "child_info.h"
|
2008-02-28 23:50:51 +08:00
|
|
|
#include "ntdll.h"
|
2010-02-28 23:54:25 +08:00
|
|
|
#include "exception.h"
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2011-07-07 00:33:30 +08:00
|
|
|
#define CALL_HANDLER_RETRY_OUTER 10
|
|
|
|
#define CALL_HANDLER_RETRY_INNER 10
|
2000-11-07 07:12:05 +08:00
|
|
|
|
2008-02-15 00:47:11 +08:00
|
|
|
char debugger_command[2 * NT_MAX_PATH + 20];
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
extern void sigdelayed ();
|
|
|
|
};
|
|
|
|
|
|
|
|
static BOOL WINAPI ctrl_c_handler (DWORD);
|
|
|
|
|
|
|
|
/* This is set to indicate that we have already exited. */
|
|
|
|
|
|
|
|
static NO_COPY int exit_already = 0;
|
2005-12-24 06:50:20 +08:00
|
|
|
static muto NO_COPY mask_sync;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2001-10-13 09:35:15 +08:00
|
|
|
NO_COPY static struct
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
unsigned int code;
|
|
|
|
const char *name;
|
2001-10-13 09:35:15 +08:00
|
|
|
} status_info[] =
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
#define X(s) s, #s
|
|
|
|
{ X (STATUS_ABANDONED_WAIT_0) },
|
|
|
|
{ X (STATUS_ACCESS_VIOLATION) },
|
|
|
|
{ X (STATUS_ARRAY_BOUNDS_EXCEEDED) },
|
|
|
|
{ X (STATUS_BREAKPOINT) },
|
|
|
|
{ X (STATUS_CONTROL_C_EXIT) },
|
|
|
|
{ X (STATUS_DATATYPE_MISALIGNMENT) },
|
|
|
|
{ X (STATUS_FLOAT_DENORMAL_OPERAND) },
|
|
|
|
{ X (STATUS_FLOAT_DIVIDE_BY_ZERO) },
|
|
|
|
{ X (STATUS_FLOAT_INEXACT_RESULT) },
|
|
|
|
{ X (STATUS_FLOAT_INVALID_OPERATION) },
|
|
|
|
{ X (STATUS_FLOAT_OVERFLOW) },
|
|
|
|
{ X (STATUS_FLOAT_STACK_CHECK) },
|
|
|
|
{ X (STATUS_FLOAT_UNDERFLOW) },
|
|
|
|
{ X (STATUS_GUARD_PAGE_VIOLATION) },
|
|
|
|
{ X (STATUS_ILLEGAL_INSTRUCTION) },
|
|
|
|
{ X (STATUS_INTEGER_DIVIDE_BY_ZERO) },
|
|
|
|
{ X (STATUS_INTEGER_OVERFLOW) },
|
|
|
|
{ X (STATUS_INVALID_DISPOSITION) },
|
|
|
|
{ X (STATUS_IN_PAGE_ERROR) },
|
|
|
|
{ X (STATUS_NONCONTINUABLE_EXCEPTION) },
|
|
|
|
{ X (STATUS_NO_MEMORY) },
|
|
|
|
{ X (STATUS_PENDING) },
|
|
|
|
{ X (STATUS_PRIVILEGED_INSTRUCTION) },
|
|
|
|
{ X (STATUS_SINGLE_STEP) },
|
|
|
|
{ X (STATUS_STACK_OVERFLOW) },
|
|
|
|
{ X (STATUS_TIMEOUT) },
|
|
|
|
{ X (STATUS_USER_APC) },
|
|
|
|
{ X (STATUS_WAIT_0) },
|
|
|
|
{ 0, 0 }
|
|
|
|
#undef X
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Initialization code. */
|
|
|
|
|
|
|
|
void
|
2006-03-16 10:57:37 +08:00
|
|
|
init_console_handler (bool install_handler)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2005-06-30 10:52:14 +08:00
|
|
|
BOOL res;
|
2006-03-19 03:17:21 +08:00
|
|
|
|
2006-03-22 11:20:28 +08:00
|
|
|
SetConsoleCtrlHandler (ctrl_c_handler, FALSE);
|
2007-02-23 18:51:59 +08:00
|
|
|
SetConsoleCtrlHandler (NULL, FALSE);
|
2005-06-30 10:52:14 +08:00
|
|
|
if (install_handler)
|
|
|
|
res = SetConsoleCtrlHandler (ctrl_c_handler, TRUE);
|
|
|
|
else
|
2007-02-23 18:51:59 +08:00
|
|
|
res = SetConsoleCtrlHandler (NULL, TRUE);
|
2005-06-30 10:52:14 +08:00
|
|
|
if (!res)
|
2002-01-10 11:21:27 +08:00
|
|
|
system_printf ("SetConsoleCtrlHandler failed, %E");
|
2003-09-12 14:41:53 +08:00
|
|
|
}
|
2002-01-10 11:21:27 +08:00
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
extern "C" void
|
|
|
|
error_start_init (const char *buf)
|
|
|
|
{
|
|
|
|
if (!buf || !*buf)
|
|
|
|
{
|
|
|
|
debugger_command[0] = '\0';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-02-15 00:47:11 +08:00
|
|
|
char pgm[NT_MAX_PATH];
|
|
|
|
if (!GetModuleFileName (NULL, pgm, NT_MAX_PATH))
|
2002-07-15 11:48:52 +08:00
|
|
|
strcpy (pgm, "cygwin1.dll");
|
|
|
|
for (char *p = strchr (pgm, '\\'); p; p = strchr (p, '\\'))
|
|
|
|
*p = '/';
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2003-06-09 21:29:12 +08:00
|
|
|
__small_sprintf (debugger_command, "%s \"%s\"", buf, pgm);
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
|
2001-04-30 11:09:19 +08:00
|
|
|
static void
|
|
|
|
open_stackdumpfile ()
|
|
|
|
{
|
2010-08-18 22:22:07 +08:00
|
|
|
/* If we have no executable name, or if the CWD handle is NULL,
|
|
|
|
which means, the CWD is a virtual path, don't even try to open
|
|
|
|
a stackdump file. */
|
|
|
|
if (myself->progname[0] && cygheap->cwd.get_handle ())
|
2001-04-30 11:09:19 +08:00
|
|
|
{
|
2010-05-18 22:30:51 +08:00
|
|
|
const WCHAR *p;
|
2001-04-30 11:09:19 +08:00
|
|
|
/* write to progname.stackdump if possible */
|
2001-09-07 02:06:27 +08:00
|
|
|
if (!myself->progname[0])
|
2010-05-18 22:30:51 +08:00
|
|
|
p = L"unknown";
|
|
|
|
else if ((p = wcsrchr (myself->progname, L'\\')))
|
2001-04-30 11:09:19 +08:00
|
|
|
p++;
|
|
|
|
else
|
|
|
|
p = myself->progname;
|
2008-02-28 23:50:51 +08:00
|
|
|
|
2010-05-18 22:30:51 +08:00
|
|
|
WCHAR corefile[wcslen (p) + sizeof (".stackdump")];
|
2010-06-01 22:51:47 +08:00
|
|
|
wcpcpy (wcpcpy(corefile, p), L".stackdump");
|
2008-02-28 23:50:51 +08:00
|
|
|
UNICODE_STRING ucore;
|
|
|
|
OBJECT_ATTRIBUTES attr;
|
2008-02-29 01:09:34 +08:00
|
|
|
/* Create the UNICODE variation of <progname>.stackdump. */
|
2010-05-18 22:30:51 +08:00
|
|
|
RtlInitUnicodeString (&ucore, corefile);
|
2008-02-29 01:09:34 +08:00
|
|
|
/* Create an object attribute which refers to <progname>.stackdump
|
2008-07-17 04:20:45 +08:00
|
|
|
in Cygwin's cwd. Stick to caseinsensitivity. */
|
2008-02-28 23:50:51 +08:00
|
|
|
InitializeObjectAttributes (&attr, &ucore, OBJ_CASE_INSENSITIVE,
|
|
|
|
cygheap->cwd.get_handle (), NULL);
|
|
|
|
HANDLE h;
|
|
|
|
IO_STATUS_BLOCK io;
|
|
|
|
NTSTATUS status;
|
2008-02-29 01:09:34 +08:00
|
|
|
/* Try to open it to dump the stack in it. */
|
2008-02-28 23:50:51 +08:00
|
|
|
status = NtCreateFile (&h, GENERIC_WRITE | SYNCHRONIZE, &attr, &io,
|
|
|
|
NULL, FILE_ATTRIBUTE_NORMAL, 0, FILE_OVERWRITE_IF,
|
|
|
|
FILE_SYNCHRONOUS_IO_NONALERT
|
2009-05-04 17:16:42 +08:00
|
|
|
| FILE_OPEN_FOR_BACKUP_INTENT, NULL, 0);
|
2008-02-28 23:50:51 +08:00
|
|
|
if (NT_SUCCESS (status))
|
2001-04-30 11:09:19 +08:00
|
|
|
{
|
2004-11-26 12:15:10 +08:00
|
|
|
if (!myself->cygstarted)
|
2008-03-03 06:51:19 +08:00
|
|
|
system_printf ("Dumping stack trace to %S", &ucore);
|
2001-10-03 11:49:26 +08:00
|
|
|
else
|
2008-03-03 06:51:19 +08:00
|
|
|
debug_printf ("Dumping stack trace to %S", &ucore);
|
2001-04-30 11:09:19 +08:00
|
|
|
SetStdHandle (STD_ERROR_HANDLE, h);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
/* Utilities for dumping the stack, etc. */
|
|
|
|
|
|
|
|
static void
|
2010-02-28 23:54:25 +08:00
|
|
|
dump_exception (EXCEPTION_RECORD *e, CONTEXT *in)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2000-08-03 03:26:01 +08:00
|
|
|
const char *exception_name = NULL;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
if (e)
|
|
|
|
{
|
|
|
|
for (int i = 0; status_info[i].name; i++)
|
|
|
|
{
|
|
|
|
if (status_info[i].code == e->ExceptionCode)
|
|
|
|
{
|
|
|
|
exception_name = status_info[i].name;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (exception_name)
|
|
|
|
small_printf ("Exception: %s at eip=%08x\r\n", exception_name, in->Eip);
|
|
|
|
else
|
2006-02-07 02:24:11 +08:00
|
|
|
small_printf ("Signal %d at eip=%08x\r\n", e->ExceptionCode, in->Eip);
|
2000-02-18 03:38:33 +08:00
|
|
|
small_printf ("eax=%08x ebx=%08x ecx=%08x edx=%08x esi=%08x edi=%08x\r\n",
|
2004-03-12 10:07:39 +08:00
|
|
|
in->Eax, in->Ebx, in->Ecx, in->Edx, in->Esi, in->Edi);
|
2010-06-29 18:28:40 +08:00
|
|
|
small_printf ("ebp=%08x esp=%08x program=%W, pid %u, thread %s\r\n",
|
2004-03-12 10:07:39 +08:00
|
|
|
in->Ebp, in->Esp, myself->progname, myself->pid, cygthread::name ());
|
2000-02-18 03:38:33 +08:00
|
|
|
small_printf ("cs=%04x ds=%04x es=%04x fs=%04x gs=%04x ss=%04x\r\n",
|
2004-03-12 10:07:39 +08:00
|
|
|
in->SegCs, in->SegDs, in->SegEs, in->SegFs, in->SegGs, in->SegSs);
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* A class for manipulating the stack. */
|
|
|
|
class stack_info
|
|
|
|
{
|
2000-07-05 03:07:35 +08:00
|
|
|
int walk (); /* Uses the "old" method */
|
2000-07-04 04:14:06 +08:00
|
|
|
char *next_offset () {return *((char **) sf.AddrFrame.Offset);}
|
2001-05-05 10:44:36 +08:00
|
|
|
bool needargs;
|
|
|
|
DWORD dummy_frame;
|
2000-02-18 03:38:33 +08:00
|
|
|
public:
|
2001-05-05 10:44:36 +08:00
|
|
|
STACKFRAME sf; /* For storing the stack information */
|
|
|
|
void init (DWORD, bool, bool); /* Called the first time that stack info is needed */
|
2000-03-10 05:04:05 +08:00
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
/* Postfix ++ iterates over the stack, returning zero when nothing is left. */
|
2003-02-04 11:01:17 +08:00
|
|
|
int operator ++(int) { return walk (); }
|
2000-02-18 03:38:33 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* The number of parameters used in STACKFRAME */
|
2000-07-05 03:07:35 +08:00
|
|
|
#define NPARAMS (sizeof (thestack.sf.Params) / sizeof (thestack.sf.Params[0]))
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
/* This is the main stack frame info for this process. */
|
2000-03-10 05:04:05 +08:00
|
|
|
static NO_COPY stack_info thestack;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
/* Initialize everything needed to start iterating. */
|
|
|
|
void
|
2001-05-05 10:44:36 +08:00
|
|
|
stack_info::init (DWORD ebp, bool wantargs, bool goodframe)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2001-04-30 11:09:19 +08:00
|
|
|
# define debp ((DWORD *) ebp)
|
2000-07-05 03:07:35 +08:00
|
|
|
memset (&sf, 0, sizeof (sf));
|
2001-05-05 10:44:36 +08:00
|
|
|
if (!goodframe)
|
|
|
|
sf.AddrFrame.Offset = ebp;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dummy_frame = ebp;
|
|
|
|
sf.AddrFrame.Offset = (DWORD) &dummy_frame;
|
|
|
|
}
|
2001-04-30 11:09:19 +08:00
|
|
|
sf.AddrReturn.Offset = debp[1];
|
2000-02-18 03:38:33 +08:00
|
|
|
sf.AddrFrame.Mode = AddrModeFlat;
|
2001-05-05 10:44:36 +08:00
|
|
|
needargs = wantargs;
|
2001-04-30 11:09:19 +08:00
|
|
|
# undef debp
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
|
2008-08-02 03:12:49 +08:00
|
|
|
extern "C" void _cygwin_exit_return ();
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
/* Walk the stack by looking at successive stored 'bp' frames.
|
|
|
|
This is not foolproof. */
|
|
|
|
int
|
2000-03-10 05:04:05 +08:00
|
|
|
stack_info::walk ()
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
char **ebp;
|
2008-08-02 03:12:49 +08:00
|
|
|
|
|
|
|
if ((void (*) ()) sf.AddrPC.Offset == _cygwin_exit_return)
|
|
|
|
return 0; /* stack frames are exhausted */
|
|
|
|
|
2008-03-03 06:51:19 +08:00
|
|
|
if (((ebp = (char **) next_offset ()) == NULL) || (ebp >= (char **) cygwin_hmodule))
|
2000-02-18 03:38:33 +08:00
|
|
|
return 0;
|
|
|
|
|
2001-05-05 10:44:36 +08:00
|
|
|
sf.AddrFrame.Offset = (DWORD) ebp;
|
|
|
|
sf.AddrPC.Offset = sf.AddrReturn.Offset;
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
/* The return address always follows the stack pointer */
|
|
|
|
sf.AddrReturn.Offset = (DWORD) *++ebp;
|
|
|
|
|
2001-05-05 10:44:36 +08:00
|
|
|
if (needargs)
|
2008-02-13 17:42:22 +08:00
|
|
|
{
|
|
|
|
unsigned nparams = NPARAMS;
|
|
|
|
|
|
|
|
/* The arguments follow the return address */
|
|
|
|
sf.Params[0] = (DWORD) *++ebp;
|
|
|
|
/* Hack for XP/2K3 WOW64. If the first stack param points to the
|
|
|
|
application entry point, we can only fetch one additional
|
|
|
|
parameter. Accessing anything beyond this address results in
|
|
|
|
a SEGV. This is fixed in Vista/2K8 WOW64. */
|
|
|
|
if (wincap.has_restricted_stack_args () && sf.Params[0] == 0x401000)
|
|
|
|
nparams = 2;
|
2008-02-28 02:08:52 +08:00
|
|
|
for (unsigned i = 1; i < nparams; i++)
|
2008-02-13 17:42:22 +08:00
|
|
|
sf.Params[i] = (DWORD) *++ebp;
|
|
|
|
}
|
2001-05-05 10:44:36 +08:00
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2011-11-27 03:14:22 +08:00
|
|
|
void
|
2001-05-05 10:44:36 +08:00
|
|
|
stackdump (DWORD ebp, int open_file, bool isexception)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2006-02-20 10:04:31 +08:00
|
|
|
static bool already_dumped;
|
2001-04-30 11:09:19 +08:00
|
|
|
|
2010-04-20 18:44:52 +08:00
|
|
|
if (cygheap->rlim_core == 0UL || (open_file && already_dumped))
|
2001-04-30 11:09:19 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (open_file)
|
|
|
|
open_stackdumpfile ();
|
|
|
|
|
2006-02-20 10:04:31 +08:00
|
|
|
already_dumped = true;
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
int i;
|
|
|
|
|
2001-05-05 10:44:36 +08:00
|
|
|
thestack.init (ebp, 1, !isexception); /* Initialize from the input CONTEXT */
|
2000-02-18 03:38:33 +08:00
|
|
|
small_printf ("Stack trace:\r\nFrame Function Args\r\n");
|
2000-07-04 04:14:06 +08:00
|
|
|
for (i = 0; i < 16 && thestack++; i++)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2000-03-10 05:04:05 +08:00
|
|
|
small_printf ("%08x %08x ", thestack.sf.AddrFrame.Offset,
|
|
|
|
thestack.sf.AddrPC.Offset);
|
2000-02-18 03:38:33 +08:00
|
|
|
for (unsigned j = 0; j < NPARAMS; j++)
|
2000-03-10 05:04:05 +08:00
|
|
|
small_printf ("%s%08x", j == 0 ? " (" : ", ", thestack.sf.Params[j]);
|
2000-02-18 03:38:33 +08:00
|
|
|
small_printf (")\r\n");
|
|
|
|
}
|
2004-03-12 10:07:39 +08:00
|
|
|
small_printf ("End of stack trace%s\n",
|
2000-02-18 03:38:33 +08:00
|
|
|
i == 16 ? " (more stack frames may be present)" : "");
|
|
|
|
}
|
|
|
|
|
2007-07-29 13:22:05 +08:00
|
|
|
bool
|
|
|
|
_cygtls::inside_kernel (CONTEXT *cx)
|
2005-12-28 04:07:59 +08:00
|
|
|
{
|
|
|
|
int res;
|
|
|
|
MEMORY_BASIC_INFORMATION m;
|
2006-02-24 03:21:21 +08:00
|
|
|
|
2007-07-29 13:22:05 +08:00
|
|
|
if (!isinitialized ())
|
2006-02-24 03:21:21 +08:00
|
|
|
return true;
|
2005-12-28 04:07:59 +08:00
|
|
|
|
|
|
|
memset (&m, 0, sizeof m);
|
|
|
|
if (!VirtualQuery ((LPCVOID) cx->Eip, &m, sizeof m))
|
|
|
|
sigproc_printf ("couldn't get memory info, pc %p, %E", cx->Eip);
|
|
|
|
|
2008-04-03 23:28:03 +08:00
|
|
|
size_t size = (windows_system_directory_length + 6) * sizeof (WCHAR);
|
|
|
|
PWCHAR checkdir = (PWCHAR) alloca (size);
|
|
|
|
memset (checkdir, 0, size);
|
2005-12-28 04:07:59 +08:00
|
|
|
|
|
|
|
# define h ((HMODULE) m.AllocationBase)
|
2011-12-14 04:06:31 +08:00
|
|
|
if (!h || m.State != MEM_COMMIT) /* Be defensive */
|
2005-12-28 04:07:59 +08:00
|
|
|
res = true;
|
2006-02-24 03:21:21 +08:00
|
|
|
else if (h == user_data->hmodule)
|
|
|
|
res = false;
|
2008-04-03 23:28:03 +08:00
|
|
|
else if (!GetModuleFileNameW (h, checkdir, windows_system_directory_length + 6))
|
2006-02-24 03:21:21 +08:00
|
|
|
res = false;
|
2005-12-28 04:07:59 +08:00
|
|
|
else
|
2008-04-03 23:28:03 +08:00
|
|
|
{
|
|
|
|
/* Skip potential long path prefix. */
|
|
|
|
if (!wcsncmp (checkdir, L"\\\\?\\", 4))
|
|
|
|
checkdir += 4;
|
2011-12-14 04:06:31 +08:00
|
|
|
res = wcsncasecmp (windows_system_directory, checkdir,
|
|
|
|
windows_system_directory_length) == 0;
|
|
|
|
if (!res && system_wow64_directory_length)
|
|
|
|
res = wcsncasecmp (system_wow64_directory, checkdir,
|
|
|
|
system_wow64_directory_length) == 0;
|
|
|
|
|
2008-04-03 23:28:03 +08:00
|
|
|
}
|
2006-02-24 03:21:21 +08:00
|
|
|
sigproc_printf ("pc %p, h %p, inside_kernel %d", cx->Eip, h, res);
|
2005-12-28 04:07:59 +08:00
|
|
|
# undef h
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
/* Temporary (?) function for external callers to get a stack dump */
|
|
|
|
extern "C" void
|
2000-07-05 03:07:35 +08:00
|
|
|
cygwin_stackdump ()
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
CONTEXT c;
|
|
|
|
c.ContextFlags = CONTEXT_FULL;
|
2000-05-07 11:29:08 +08:00
|
|
|
GetThreadContext (GetCurrentThread (), &c);
|
2001-05-05 10:44:36 +08:00
|
|
|
stackdump (c.Ebp, 0, 0);
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
|
2000-07-05 03:07:35 +08:00
|
|
|
#define TIME_TO_WAIT_FOR_DEBUGGER 10000
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
extern "C" int
|
2001-04-30 11:09:19 +08:00
|
|
|
try_to_debug (bool waitloop)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2001-01-28 13:51:15 +08:00
|
|
|
debug_printf ("debugger_command '%s'", debugger_command);
|
2005-07-17 08:51:03 +08:00
|
|
|
if (*debugger_command == '\0')
|
2000-02-18 03:38:33 +08:00
|
|
|
return 0;
|
2005-07-17 08:51:03 +08:00
|
|
|
if (being_debugged ())
|
|
|
|
{
|
2006-06-03 10:58:59 +08:00
|
|
|
extern void break_here ();
|
|
|
|
break_here ();
|
2005-07-17 08:51:03 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
__small_sprintf (strchr (debugger_command, '\0'), " %u", GetCurrentProcessId ());
|
|
|
|
|
2003-02-07 23:00:57 +08:00
|
|
|
LONG prio = GetThreadPriority (GetCurrentThread ());
|
|
|
|
SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_HIGHEST);
|
2000-02-23 12:07:13 +08:00
|
|
|
PROCESS_INFORMATION pi = {NULL, 0, 0, 0};
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2007-12-12 20:12:24 +08:00
|
|
|
STARTUPINFOW si = {0, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL};
|
2000-02-18 03:38:33 +08:00
|
|
|
si.lpReserved = NULL;
|
|
|
|
si.lpDesktop = NULL;
|
|
|
|
si.dwFlags = 0;
|
|
|
|
si.cb = sizeof (si);
|
|
|
|
|
|
|
|
/* FIXME: need to know handles of all running threads to
|
|
|
|
suspend_all_threads_except (current_thread_id);
|
|
|
|
*/
|
|
|
|
|
2010-10-24 23:26:05 +08:00
|
|
|
/* If the tty mutex is owned, we will fail to start any cygwin app
|
|
|
|
until the trapped app exits. However, this will only release any
|
|
|
|
the mutex if it is owned by this thread so that may be problematic. */
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2006-06-04 04:32:07 +08:00
|
|
|
lock_ttys::release ();
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2000-07-05 03:07:35 +08:00
|
|
|
/* prevent recursive exception handling */
|
2008-04-03 23:28:03 +08:00
|
|
|
PWCHAR rawenv = GetEnvironmentStringsW () ;
|
|
|
|
for (PWCHAR p = rawenv; *p != L'\0'; p = wcschr (p, L'\0') + 1)
|
2000-07-05 03:07:35 +08:00
|
|
|
{
|
2008-04-03 23:28:03 +08:00
|
|
|
if (wcsncmp (p, L"CYGWIN=", wcslen (L"CYGWIN=")) == 0)
|
2000-07-05 03:07:35 +08:00
|
|
|
{
|
2008-04-03 23:28:03 +08:00
|
|
|
PWCHAR q = wcsstr (p, L"error_start") ;
|
2000-07-05 03:07:35 +08:00
|
|
|
/* replace 'error_start=...' with '_rror_start=...' */
|
2003-12-27 08:25:02 +08:00
|
|
|
if (q)
|
|
|
|
{
|
2008-04-03 23:28:03 +08:00
|
|
|
*q = L'_' ;
|
|
|
|
SetEnvironmentVariableW (L"CYGWIN", p + wcslen (L"CYGWIN=")) ;
|
2003-12-27 08:25:02 +08:00
|
|
|
}
|
2000-07-05 03:07:35 +08:00
|
|
|
break ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-15 23:50:20 +08:00
|
|
|
console_printf ("*** starting debugger for pid %u, tid %u\n",
|
|
|
|
cygwin_pid (GetCurrentProcessId ()), GetCurrentThreadId ());
|
2002-07-15 11:48:52 +08:00
|
|
|
BOOL dbg;
|
2008-12-31 02:18:09 +08:00
|
|
|
WCHAR dbg_cmd[strlen(debugger_command)];
|
|
|
|
sys_mbstowcs (dbg_cmd, strlen(debugger_command) + 1, debugger_command);
|
2007-12-12 20:12:24 +08:00
|
|
|
dbg = CreateProcessW (NULL,
|
|
|
|
dbg_cmd,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
FALSE,
|
|
|
|
CREATE_NEW_CONSOLE | CREATE_NEW_PROCESS_GROUP,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
&si,
|
|
|
|
&pi);
|
2001-04-30 11:09:19 +08:00
|
|
|
|
2001-11-24 11:11:39 +08:00
|
|
|
if (!dbg)
|
2004-09-03 09:53:12 +08:00
|
|
|
system_printf ("Failed to start debugger, %E");
|
2001-11-24 11:11:39 +08:00
|
|
|
else
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2001-04-30 11:09:19 +08:00
|
|
|
if (!waitloop)
|
2004-02-09 03:59:27 +08:00
|
|
|
return dbg;
|
2003-02-14 10:52:29 +08:00
|
|
|
SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_IDLE);
|
2002-05-27 10:25:28 +08:00
|
|
|
while (!being_debugged ())
|
2010-03-13 07:13:48 +08:00
|
|
|
yield ();
|
2004-01-27 02:52:02 +08:00
|
|
|
Sleep (2000);
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
|
2004-02-09 03:59:27 +08:00
|
|
|
console_printf ("*** continuing pid %u from debugger call (%d)\n",
|
|
|
|
cygwin_pid (GetCurrentProcessId ()), dbg);
|
|
|
|
|
2003-11-29 04:55:59 +08:00
|
|
|
SetThreadPriority (GetCurrentThread (), prio);
|
2004-02-09 03:59:27 +08:00
|
|
|
return dbg;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
|
2005-12-03 12:23:35 +08:00
|
|
|
extern "C" DWORD __stdcall RtlUnwind (void *, void *, void *, DWORD);
|
2005-12-03 13:01:51 +08:00
|
|
|
static void __stdcall rtl_unwind (exception_list *, PEXCEPTION_RECORD) __attribute__ ((noinline, regparm (3)));
|
2005-12-03 12:23:35 +08:00
|
|
|
void __stdcall
|
2005-12-03 13:01:51 +08:00
|
|
|
rtl_unwind (exception_list *frame, PEXCEPTION_RECORD e)
|
2005-12-03 12:23:35 +08:00
|
|
|
{
|
|
|
|
__asm__ ("\n\
|
|
|
|
pushl %%ebx \n\
|
|
|
|
pushl %%edi \n\
|
|
|
|
pushl %%esi \n\
|
|
|
|
pushl $0 \n\
|
|
|
|
pushl %1 \n\
|
|
|
|
pushl $1f \n\
|
|
|
|
pushl %0 \n\
|
|
|
|
call _RtlUnwind@16 \n\
|
|
|
|
1: \n\
|
|
|
|
popl %%esi \n\
|
|
|
|
popl %%edi \n\
|
|
|
|
popl %%ebx \n\
|
|
|
|
": : "r" (frame), "r" (e));
|
|
|
|
}
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
/* Main exception handler. */
|
|
|
|
|
2008-03-12 20:41:50 +08:00
|
|
|
extern exception_list *_except_list asm ("%fs:0");
|
|
|
|
|
2005-12-03 12:23:35 +08:00
|
|
|
int
|
2010-02-28 23:54:25 +08:00
|
|
|
exception::handle (EXCEPTION_RECORD *e, exception_list *frame, CONTEXT *in, void *)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2005-05-19 07:30:02 +08:00
|
|
|
static bool NO_COPY debugging;
|
|
|
|
static int NO_COPY recursed;
|
2005-07-03 10:40:30 +08:00
|
|
|
_cygtls& me = _my_tls;
|
2001-04-30 11:09:19 +08:00
|
|
|
|
2001-05-24 13:20:17 +08:00
|
|
|
if (debugging && ++debugging < 500000)
|
2001-05-05 13:07:20 +08:00
|
|
|
{
|
2009-12-21 17:38:25 +08:00
|
|
|
SetThreadPriority (hMainThread, THREAD_PRIORITY_NORMAL);
|
2001-05-05 13:07:20 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
/* If we've already exited, don't do anything here. Returning 1
|
|
|
|
tells Windows to keep looking for an exception handler. */
|
2005-12-03 12:23:35 +08:00
|
|
|
if (exit_already || e->ExceptionFlags)
|
2000-02-18 03:38:33 +08:00
|
|
|
return 1;
|
|
|
|
|
2006-02-07 02:24:11 +08:00
|
|
|
siginfo_t si = {0};
|
2005-09-26 22:51:48 +08:00
|
|
|
si.si_code = SI_KERNEL;
|
2000-02-18 03:38:33 +08:00
|
|
|
/* Coerce win32 value to posix value. */
|
2005-12-03 12:23:35 +08:00
|
|
|
switch (e->ExceptionCode)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
case STATUS_FLOAT_DENORMAL_OPERAND:
|
|
|
|
case STATUS_FLOAT_DIVIDE_BY_ZERO:
|
|
|
|
case STATUS_FLOAT_INVALID_OPERATION:
|
|
|
|
case STATUS_FLOAT_STACK_CHECK:
|
2004-01-19 13:46:54 +08:00
|
|
|
si.si_signo = SIGFPE;
|
2005-09-26 21:23:47 +08:00
|
|
|
si.si_code = FPE_FLTSUB;
|
2004-01-19 13:46:54 +08:00
|
|
|
break;
|
|
|
|
case STATUS_FLOAT_INEXACT_RESULT:
|
|
|
|
si.si_signo = SIGFPE;
|
2005-09-26 21:23:47 +08:00
|
|
|
si.si_code = FPE_FLTRES;
|
2004-01-19 13:46:54 +08:00
|
|
|
break;
|
|
|
|
case STATUS_FLOAT_OVERFLOW:
|
|
|
|
si.si_signo = SIGFPE;
|
2005-09-26 21:23:47 +08:00
|
|
|
si.si_code = FPE_FLTOVF;
|
2004-01-19 13:46:54 +08:00
|
|
|
break;
|
2000-02-18 03:38:33 +08:00
|
|
|
case STATUS_FLOAT_UNDERFLOW:
|
2004-01-19 13:46:54 +08:00
|
|
|
si.si_signo = SIGFPE;
|
2005-09-26 21:23:47 +08:00
|
|
|
si.si_code = FPE_FLTUND;
|
2004-01-19 13:46:54 +08:00
|
|
|
break;
|
2000-02-18 03:38:33 +08:00
|
|
|
case STATUS_INTEGER_DIVIDE_BY_ZERO:
|
2004-01-19 13:46:54 +08:00
|
|
|
si.si_signo = SIGFPE;
|
2005-09-26 21:23:47 +08:00
|
|
|
si.si_code = FPE_INTDIV;
|
2004-01-19 13:46:54 +08:00
|
|
|
break;
|
2000-02-18 03:38:33 +08:00
|
|
|
case STATUS_INTEGER_OVERFLOW:
|
2004-01-19 13:46:54 +08:00
|
|
|
si.si_signo = SIGFPE;
|
2005-09-26 21:23:47 +08:00
|
|
|
si.si_code = FPE_INTOVF;
|
2000-02-18 03:38:33 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case STATUS_ILLEGAL_INSTRUCTION:
|
2004-01-19 13:46:54 +08:00
|
|
|
si.si_signo = SIGILL;
|
2005-09-26 21:23:47 +08:00
|
|
|
si.si_code = ILL_ILLOPC;
|
2004-01-19 13:46:54 +08:00
|
|
|
break;
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
case STATUS_PRIVILEGED_INSTRUCTION:
|
2004-01-19 13:46:54 +08:00
|
|
|
si.si_signo = SIGILL;
|
2005-09-26 21:23:47 +08:00
|
|
|
si.si_code = ILL_PRVOPC;
|
2004-01-19 13:46:54 +08:00
|
|
|
break;
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
case STATUS_NONCONTINUABLE_EXCEPTION:
|
2004-01-19 13:46:54 +08:00
|
|
|
si.si_signo = SIGILL;
|
2005-09-26 21:23:47 +08:00
|
|
|
si.si_code = ILL_ILLADR;
|
2000-02-18 03:38:33 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case STATUS_TIMEOUT:
|
2004-01-19 13:46:54 +08:00
|
|
|
si.si_signo = SIGALRM;
|
2000-02-18 03:38:33 +08:00
|
|
|
break;
|
|
|
|
|
2005-12-02 04:52:00 +08:00
|
|
|
case STATUS_GUARD_PAGE_VIOLATION:
|
|
|
|
si.si_signo = SIGBUS;
|
|
|
|
si.si_code = BUS_OBJERR;
|
|
|
|
break;
|
|
|
|
|
2005-12-28 04:07:59 +08:00
|
|
|
case STATUS_DATATYPE_MISALIGNMENT:
|
|
|
|
si.si_signo = SIGBUS;
|
|
|
|
si.si_code = BUS_ADRALN;
|
|
|
|
break;
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
case STATUS_ACCESS_VIOLATION:
|
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/version.h: Bump DLL version to 1.7.0.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* select.h: Remove.
* fhandler_socket.cc: Don't include select.h.
* select.cc: Ditto.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* cygtls.h: Drop socket related includes.
(struct _local_storage): Remove exitsock and exitsock_sin. Add
select_sockevt.
* cygtls.cc: Accomodate above change throughout.
* fhandler.h (class fhandler_socket): Make wsock_evt public.
* fhandler_socket.cc (fhandler_socket::fhandler_socket): Accomodate
reordering members.
(fhandler_socket::evaluate_events): Drop FD_CONNECT event as soon as
it gets read once. Never remove FD_WRITE event here.
(fhandler_socket::wait_for_events): Wait 50 ms instead of INFINITE for
socket events.
(fhandler_socket::accept): Fix conditional. Set wsock_events members
of accepted socket to useful start values.
(fhandler_socket::recv_internal): Always drop FD_READ/FD_OOB events from
wsock_events after the call to WSARecvFrom.
(fhandler_socket::send_internal): Drop FD_WRITE event from wsock_events
if the call to WSASendTo fails with WSAEWOULDBLOCK. Fix return value
condition.
* select.cc (struct socketinf): Change to accomodate using socket event
handling.
(peek_socket): Use event handling for peeking socket.
(thread_socket): Ditto.
(start_thread_socket): Ditto.
(socket_cleanup): Same here.
* tlsoffsets.h: Regenerate.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Rearrange slightly to keep
event handling methods and members together. Drop owner status flag.
Split wait method. Rename event handling methods for readability.
* fhandler_socket.cc (struct wsa_event): Add owner field.
(LOCK_EVENTS): New macro.
(UNLOCK_EVENTS): Ditto.
(fhandler_socket::init_events): rename from prepare.
(fhandler_socket::evaluate_events): First half of former wait method.
Do everything but wait. Allow specifiying whether or not events from
event_mask should be erased from wsock_events->events. Simplify
OOB handling. Allow sending SIGURG to any process (group).
(fhandler_socket::wait_for_events): Second half of former wait method.
Call evaluate_events and wait in a loop if socket is blocking.
(fhandler_socket::release_events): Rename from release.
(fhandler_socket::connect): Accomodate above name changes.
(fhandler_socket::accept): Ditto.
(fhandler_socket::recv_internal): Ditto.
(fhandler_socket::send_internal): Ditto.
(fhandler_socket::close): Ditto.
(fhandler_socket::fcntl): Always set owner to given input value on
F_SETOWN. Handle F_GETOWN.
* net.cc (fdsock): Accomodate above name changes.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Set Winsock errno to
WSAEWOULDBLOCK instead of WSAEINPROGRESS.
2006-07-18 Brian Ford <Brian.Ford@FlightSafety.com>
Corinna Vinschen <corinna@vinschen.de>
* winsup.h (mmap_region_status): New enum.
(mmap_is_attached_or_noreserve_page): Adjust prototype and rename
as below.
* mmap.cc (mmap_is_attached_or_noreserve_page): Rename
mmap_is_attached_or_noreserve. Add region length parameter.
Return enum above.
* exceptions.cc (_cygtls::handle_exceptions): Accomodate above.
* fhandler.cc (fhandler_base::raw_read): Call above for NOACCESS
errors and retry on success to allow reads into untouched
MAP_NORESERVE buffers.
2006-07-18 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din (posix_openpt): Export.
* tty.cc (posix_openpt): New function.
* include/cygwin/stdlib.h (posix_openpt): Declare.
* include/cygwin/version.h: Bump API minor number.
2006-07-14 Corinna Vinschen <corinna@vinschen.de>
* security.cc (get_token_group_sidlist): Always add the interactive
group to the token. Add comment. Create logon_id group SID by
copying it from incoming group list.
(create_token): Add subauth_token parameter. Use information in
subauth_token if present. Tweak SourceIdentifier if subauth_token
is present for debugging purposes.
* security.h (create_token): Add subauth_token parameter in declaration.
* syscalls.cc (seteuid32): Call subauth first. Call create_token
regardless. Use subauth token in call to create_token if subauth
succeeded.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* include/netinet/in.h: Update copyright.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Rework function so that
WaitForMultipleObjects is really only called when necessary.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* include/netdb.h: Declare rcmd, rcmd_af, rexec, rresvport,
rresvport_af, iruserok, iruserok_sa, ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* Makefile.in (DLL_OFILES): Drop iruserok.o. Add rcmd.o.
* autoload.cc (rcmd): Drop definition.
* cygwin.din: Export bindresvport, bindresvport_sa, iruserok_sa,
rcmd_af, rresvport_af.
* net.cc (cygwin_rcmd): Remove.
(last_used_bindresvport): Rename from last_used_rrecvport.
(cygwin_bindresvport_sa): New function implementing bindresvport_sa.
(cygwin_bindresvport): New function implementing bindresvport.
(cygwin_rresvport): Remove.
* include/cygwin/version.h: Bump API minor number.
* include/netinet/in.h: Declare bindresvport and bindresvport_sa.
* libc/iruserok.c: Remove file.
* libc/rcmd.cc: New file implementing rcmd, rcmd_af, rresvport,
rresvport_af, iruserok_sa, iruserok and ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::getsockname): Return valid
result for unbound sockets.
2006-07-11 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::fixup_after_fork): Handle
wsock_mtx and wsock_evt on fork, thus handling close_on_exec correctly.
(fhandler_socket::fixup_after_exec): Drop misguided attempt to handle
close_on_exec here.
(fhandler_socket::dup): Call fixup_after_fork with NULL parent.
Add comment.
(fhandler_socket::set_close_on_exec): Handle wsock_mtx and wsock_evt.
2006-07-10 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Add wsock_mtx, wsock_evt
and wsock_events members. Remove closed status flag, add listener
status flag. Accomodate new implementation of socket event handling
methods. Declare recv* and send* functions ssize_t as the POSIX
equivalents.
(fhandler_socket::recv_internal): Declare.
(fhandler_socket::send_internal): Ditto.
* fhandler_socket.cc (EVENT_MASK): Define mask of selected events.
(fhandler_socket::fhandler_socket): Initialize new members.
(fhandler_socket::af_local_setblocking): Don't actually set the
socket to blocking mode. Keep sane event selection.
(fhandler_socket::af_local_unsetblocking): Don't actually set the
socket to previous blocking setting, just remember it.
(struct wsa_event): New structure to keep event data per shared
socket.
(NUM_SOCKS): Define number of shared sockets concurrently handled by
all active Cygwin processes.
(wsa_events): New shared datastructure keeping all wsa_event records.
(socket_serial_number): New shared variable to identify shared sockets.
(wsa_slot_mtx): Global mutex to serialize wsa_events access.
(search_wsa_event_slot): New static function to select a new wsa_event
slot for a new socket.
(fhandler_socket::prepare): Rewrite. Prepare event selection
per new socket.
(fhandler_socket::wait): Rewrite. Wait for socket events in thread
safe and multiple process safe.
(fhandler_socket::release): Rewrite. Close per-socket descriptor
mutex handle and event handle.
(fhandler_socket::dup): Duplicate wsock_mtx and wsock_evt. Fix
copy-paste error in debug output.
(fhandler_socket::connect): Accomodate new event handling.
(fhandler_socket::listen): Set listener flag on successful listen.
(fhandler_socket::accept): Accomodate new event handling.
(fhandler_socket::recv_internal): New inline method centralizing
common recv code.
(fhandler_socket::recvfrom): Call recv_internal now.
(fhandler_socket::recvmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::send_internal): New inline method centralizing
common send code.
(fhandler_socket::sendto): Call send_internal now.
(fhandler_socket::sendmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::close): Call release now.
(fhandler_socket::ioctl): Never actually switch to blocking mode.
Just keep track of the setting.
* net.cc (fdsock): Call prepare now.
(cygwin_connect): Revert again to event driven technique.
(cygwin_accept): Ditto.
* poll.cc (poll): Don't call recvfrom on a listening socket.
Remove special case for failing recvfrom.
* include/sys/socket.h: Declare recv* and send* functions ssize_t as
requested by POSIX.
2006-07-07 Corinna Vinschen <corinna@vinschen.de>
* net.cc (cygwin_inet_ntop): Fix data type of forth parameter.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/in6.h (struct in6_addr): Fix typo.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din: Export in6addr_any, in6addr_loopback, freeaddrinfo,
gai_strerror, getaddrinfo, getnameinfo.
* fhandler_socket.cc: Include cygwin/in6.h.
(get_inet_addr): Accomodate AF_INET6 usage.
(fhandler_socket::connect): Ditto.
(fhandler_socket::listen): Ditto.
(fhandler_socket::sendto): Ditto.
* net.cc: Include cygwin/in6.h.
(in6addr_any): Define.
(in6addr_loopback): Define.
(cygwin_socket): Accomodate AF_INET6 usage.
(socketpair): Bind socketpairs only to loopback for security.
(inet_pton4): New static function.
(inet_pton6): Ditto.
(cygwin_inet_pton): New AF_INET6 aware inet_pton implementation.
(inet_ntop4): New static function.
(inet_ntop6): Ditto.
(cygwin_inet_ntop): New AF_INET6 aware inet_ntop implementation.
(ga_aistruct): New static function.
(ga_clone): Ditto.
(ga_echeck): Ditto.
(ga_nsearch): Ditto.
(ga_port): Ditto.
(ga_serv): Ditto.
(ga_unix): Ditto.
(gn_ipv46): Ditto.
(ipv4_freeaddrinfo): Ditto.
(ipv4_getaddrinfo): Ditto.
(ipv4_getnameinfo): Ditto.
(gai_errmap_t): New structure holding error code - error string mapping.
(cygwin_gai_strerror): New function implementing gai_strerror.
(w32_to_gai_err): New static function.
(get_ipv6_funcs): Ditto.
(load_ipv6_funcs): Ditto.
(cygwin_freeaddrinfo): New function implementing freeaddrinfo.
(cygwin_getaddrinfo): New function implementing getaddrinfo.
(cygwin_getnameinfo): New function implementing getnameinfo.
* include/netdb.h: Include stdint.h and cygwin/socket.h. Define
data types and macros used by getaddrinfo and friends. Declare
freeaddrinfo, gai_strerror, getaddrinfo and getnameinfo.
* include/cygwin/in.h: Add IPv6 related IPPROTOs. Remove definition
of struct sockaddr_in6. Include cygwin/in6.h instead.
* include/cygwin/in6.h: New header file defining IPv6 releated
data types and macros.
* include/cygwin/socket.h: Enable AF_INET6 and PF_INET6. Add
IPv6 related socket options.
* include/cygwin/version.h: Bump API minor number.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* autoload.cc (DsGetDcNameA): Define.
(NetGetAnyDCName): Define.
* security.cc: Include dsgetdc.h.
(DsGetDcNameA): Declare.
(DS_FORCE_REDISCOVERY): Define.
(get_logon_server): Add bool parameter to control rediscovery of DC.
Use DsGetDcNameA function if supported, NetGetDCName/NetGetAnyDCName
otherwise.
(get_server_groups): Rediscover DC if get_user_groups fails and
try again.
(get_reg_security): Use correct error code macro when testing
RegGetKeySecurity return value.
* security.h (get_logon_server): Remove default vaue from wserver
parameter. Add rediscovery parameter.
* uinfo.cc (cygheap_user::env_logsrv): Accomodate rediscovery parameter
in call to get_logon_server.
2006-07-26 03:23:23 +08:00
|
|
|
switch (mmap_is_attached_or_noreserve ((void *)e->ExceptionInformation[1],
|
|
|
|
1))
|
2007-02-20 08:16:18 +08:00
|
|
|
{
|
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/version.h: Bump DLL version to 1.7.0.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* select.h: Remove.
* fhandler_socket.cc: Don't include select.h.
* select.cc: Ditto.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* cygtls.h: Drop socket related includes.
(struct _local_storage): Remove exitsock and exitsock_sin. Add
select_sockevt.
* cygtls.cc: Accomodate above change throughout.
* fhandler.h (class fhandler_socket): Make wsock_evt public.
* fhandler_socket.cc (fhandler_socket::fhandler_socket): Accomodate
reordering members.
(fhandler_socket::evaluate_events): Drop FD_CONNECT event as soon as
it gets read once. Never remove FD_WRITE event here.
(fhandler_socket::wait_for_events): Wait 50 ms instead of INFINITE for
socket events.
(fhandler_socket::accept): Fix conditional. Set wsock_events members
of accepted socket to useful start values.
(fhandler_socket::recv_internal): Always drop FD_READ/FD_OOB events from
wsock_events after the call to WSARecvFrom.
(fhandler_socket::send_internal): Drop FD_WRITE event from wsock_events
if the call to WSASendTo fails with WSAEWOULDBLOCK. Fix return value
condition.
* select.cc (struct socketinf): Change to accomodate using socket event
handling.
(peek_socket): Use event handling for peeking socket.
(thread_socket): Ditto.
(start_thread_socket): Ditto.
(socket_cleanup): Same here.
* tlsoffsets.h: Regenerate.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Rearrange slightly to keep
event handling methods and members together. Drop owner status flag.
Split wait method. Rename event handling methods for readability.
* fhandler_socket.cc (struct wsa_event): Add owner field.
(LOCK_EVENTS): New macro.
(UNLOCK_EVENTS): Ditto.
(fhandler_socket::init_events): rename from prepare.
(fhandler_socket::evaluate_events): First half of former wait method.
Do everything but wait. Allow specifiying whether or not events from
event_mask should be erased from wsock_events->events. Simplify
OOB handling. Allow sending SIGURG to any process (group).
(fhandler_socket::wait_for_events): Second half of former wait method.
Call evaluate_events and wait in a loop if socket is blocking.
(fhandler_socket::release_events): Rename from release.
(fhandler_socket::connect): Accomodate above name changes.
(fhandler_socket::accept): Ditto.
(fhandler_socket::recv_internal): Ditto.
(fhandler_socket::send_internal): Ditto.
(fhandler_socket::close): Ditto.
(fhandler_socket::fcntl): Always set owner to given input value on
F_SETOWN. Handle F_GETOWN.
* net.cc (fdsock): Accomodate above name changes.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Set Winsock errno to
WSAEWOULDBLOCK instead of WSAEINPROGRESS.
2006-07-18 Brian Ford <Brian.Ford@FlightSafety.com>
Corinna Vinschen <corinna@vinschen.de>
* winsup.h (mmap_region_status): New enum.
(mmap_is_attached_or_noreserve_page): Adjust prototype and rename
as below.
* mmap.cc (mmap_is_attached_or_noreserve_page): Rename
mmap_is_attached_or_noreserve. Add region length parameter.
Return enum above.
* exceptions.cc (_cygtls::handle_exceptions): Accomodate above.
* fhandler.cc (fhandler_base::raw_read): Call above for NOACCESS
errors and retry on success to allow reads into untouched
MAP_NORESERVE buffers.
2006-07-18 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din (posix_openpt): Export.
* tty.cc (posix_openpt): New function.
* include/cygwin/stdlib.h (posix_openpt): Declare.
* include/cygwin/version.h: Bump API minor number.
2006-07-14 Corinna Vinschen <corinna@vinschen.de>
* security.cc (get_token_group_sidlist): Always add the interactive
group to the token. Add comment. Create logon_id group SID by
copying it from incoming group list.
(create_token): Add subauth_token parameter. Use information in
subauth_token if present. Tweak SourceIdentifier if subauth_token
is present for debugging purposes.
* security.h (create_token): Add subauth_token parameter in declaration.
* syscalls.cc (seteuid32): Call subauth first. Call create_token
regardless. Use subauth token in call to create_token if subauth
succeeded.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* include/netinet/in.h: Update copyright.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Rework function so that
WaitForMultipleObjects is really only called when necessary.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* include/netdb.h: Declare rcmd, rcmd_af, rexec, rresvport,
rresvport_af, iruserok, iruserok_sa, ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* Makefile.in (DLL_OFILES): Drop iruserok.o. Add rcmd.o.
* autoload.cc (rcmd): Drop definition.
* cygwin.din: Export bindresvport, bindresvport_sa, iruserok_sa,
rcmd_af, rresvport_af.
* net.cc (cygwin_rcmd): Remove.
(last_used_bindresvport): Rename from last_used_rrecvport.
(cygwin_bindresvport_sa): New function implementing bindresvport_sa.
(cygwin_bindresvport): New function implementing bindresvport.
(cygwin_rresvport): Remove.
* include/cygwin/version.h: Bump API minor number.
* include/netinet/in.h: Declare bindresvport and bindresvport_sa.
* libc/iruserok.c: Remove file.
* libc/rcmd.cc: New file implementing rcmd, rcmd_af, rresvport,
rresvport_af, iruserok_sa, iruserok and ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::getsockname): Return valid
result for unbound sockets.
2006-07-11 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::fixup_after_fork): Handle
wsock_mtx and wsock_evt on fork, thus handling close_on_exec correctly.
(fhandler_socket::fixup_after_exec): Drop misguided attempt to handle
close_on_exec here.
(fhandler_socket::dup): Call fixup_after_fork with NULL parent.
Add comment.
(fhandler_socket::set_close_on_exec): Handle wsock_mtx and wsock_evt.
2006-07-10 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Add wsock_mtx, wsock_evt
and wsock_events members. Remove closed status flag, add listener
status flag. Accomodate new implementation of socket event handling
methods. Declare recv* and send* functions ssize_t as the POSIX
equivalents.
(fhandler_socket::recv_internal): Declare.
(fhandler_socket::send_internal): Ditto.
* fhandler_socket.cc (EVENT_MASK): Define mask of selected events.
(fhandler_socket::fhandler_socket): Initialize new members.
(fhandler_socket::af_local_setblocking): Don't actually set the
socket to blocking mode. Keep sane event selection.
(fhandler_socket::af_local_unsetblocking): Don't actually set the
socket to previous blocking setting, just remember it.
(struct wsa_event): New structure to keep event data per shared
socket.
(NUM_SOCKS): Define number of shared sockets concurrently handled by
all active Cygwin processes.
(wsa_events): New shared datastructure keeping all wsa_event records.
(socket_serial_number): New shared variable to identify shared sockets.
(wsa_slot_mtx): Global mutex to serialize wsa_events access.
(search_wsa_event_slot): New static function to select a new wsa_event
slot for a new socket.
(fhandler_socket::prepare): Rewrite. Prepare event selection
per new socket.
(fhandler_socket::wait): Rewrite. Wait for socket events in thread
safe and multiple process safe.
(fhandler_socket::release): Rewrite. Close per-socket descriptor
mutex handle and event handle.
(fhandler_socket::dup): Duplicate wsock_mtx and wsock_evt. Fix
copy-paste error in debug output.
(fhandler_socket::connect): Accomodate new event handling.
(fhandler_socket::listen): Set listener flag on successful listen.
(fhandler_socket::accept): Accomodate new event handling.
(fhandler_socket::recv_internal): New inline method centralizing
common recv code.
(fhandler_socket::recvfrom): Call recv_internal now.
(fhandler_socket::recvmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::send_internal): New inline method centralizing
common send code.
(fhandler_socket::sendto): Call send_internal now.
(fhandler_socket::sendmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::close): Call release now.
(fhandler_socket::ioctl): Never actually switch to blocking mode.
Just keep track of the setting.
* net.cc (fdsock): Call prepare now.
(cygwin_connect): Revert again to event driven technique.
(cygwin_accept): Ditto.
* poll.cc (poll): Don't call recvfrom on a listening socket.
Remove special case for failing recvfrom.
* include/sys/socket.h: Declare recv* and send* functions ssize_t as
requested by POSIX.
2006-07-07 Corinna Vinschen <corinna@vinschen.de>
* net.cc (cygwin_inet_ntop): Fix data type of forth parameter.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/in6.h (struct in6_addr): Fix typo.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din: Export in6addr_any, in6addr_loopback, freeaddrinfo,
gai_strerror, getaddrinfo, getnameinfo.
* fhandler_socket.cc: Include cygwin/in6.h.
(get_inet_addr): Accomodate AF_INET6 usage.
(fhandler_socket::connect): Ditto.
(fhandler_socket::listen): Ditto.
(fhandler_socket::sendto): Ditto.
* net.cc: Include cygwin/in6.h.
(in6addr_any): Define.
(in6addr_loopback): Define.
(cygwin_socket): Accomodate AF_INET6 usage.
(socketpair): Bind socketpairs only to loopback for security.
(inet_pton4): New static function.
(inet_pton6): Ditto.
(cygwin_inet_pton): New AF_INET6 aware inet_pton implementation.
(inet_ntop4): New static function.
(inet_ntop6): Ditto.
(cygwin_inet_ntop): New AF_INET6 aware inet_ntop implementation.
(ga_aistruct): New static function.
(ga_clone): Ditto.
(ga_echeck): Ditto.
(ga_nsearch): Ditto.
(ga_port): Ditto.
(ga_serv): Ditto.
(ga_unix): Ditto.
(gn_ipv46): Ditto.
(ipv4_freeaddrinfo): Ditto.
(ipv4_getaddrinfo): Ditto.
(ipv4_getnameinfo): Ditto.
(gai_errmap_t): New structure holding error code - error string mapping.
(cygwin_gai_strerror): New function implementing gai_strerror.
(w32_to_gai_err): New static function.
(get_ipv6_funcs): Ditto.
(load_ipv6_funcs): Ditto.
(cygwin_freeaddrinfo): New function implementing freeaddrinfo.
(cygwin_getaddrinfo): New function implementing getaddrinfo.
(cygwin_getnameinfo): New function implementing getnameinfo.
* include/netdb.h: Include stdint.h and cygwin/socket.h. Define
data types and macros used by getaddrinfo and friends. Declare
freeaddrinfo, gai_strerror, getaddrinfo and getnameinfo.
* include/cygwin/in.h: Add IPv6 related IPPROTOs. Remove definition
of struct sockaddr_in6. Include cygwin/in6.h instead.
* include/cygwin/in6.h: New header file defining IPv6 releated
data types and macros.
* include/cygwin/socket.h: Enable AF_INET6 and PF_INET6. Add
IPv6 related socket options.
* include/cygwin/version.h: Bump API minor number.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* autoload.cc (DsGetDcNameA): Define.
(NetGetAnyDCName): Define.
* security.cc: Include dsgetdc.h.
(DsGetDcNameA): Declare.
(DS_FORCE_REDISCOVERY): Define.
(get_logon_server): Add bool parameter to control rediscovery of DC.
Use DsGetDcNameA function if supported, NetGetDCName/NetGetAnyDCName
otherwise.
(get_server_groups): Rediscover DC if get_user_groups fails and
try again.
(get_reg_security): Use correct error code macro when testing
RegGetKeySecurity return value.
* security.h (get_logon_server): Remove default vaue from wserver
parameter. Add rediscovery parameter.
* uinfo.cc (cygheap_user::env_logsrv): Accomodate rediscovery parameter
in call to get_logon_server.
2006-07-26 03:23:23 +08:00
|
|
|
case MMAP_NORESERVE_COMMITED:
|
2006-07-13 16:33:34 +08:00
|
|
|
return 0;
|
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/version.h: Bump DLL version to 1.7.0.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* select.h: Remove.
* fhandler_socket.cc: Don't include select.h.
* select.cc: Ditto.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* cygtls.h: Drop socket related includes.
(struct _local_storage): Remove exitsock and exitsock_sin. Add
select_sockevt.
* cygtls.cc: Accomodate above change throughout.
* fhandler.h (class fhandler_socket): Make wsock_evt public.
* fhandler_socket.cc (fhandler_socket::fhandler_socket): Accomodate
reordering members.
(fhandler_socket::evaluate_events): Drop FD_CONNECT event as soon as
it gets read once. Never remove FD_WRITE event here.
(fhandler_socket::wait_for_events): Wait 50 ms instead of INFINITE for
socket events.
(fhandler_socket::accept): Fix conditional. Set wsock_events members
of accepted socket to useful start values.
(fhandler_socket::recv_internal): Always drop FD_READ/FD_OOB events from
wsock_events after the call to WSARecvFrom.
(fhandler_socket::send_internal): Drop FD_WRITE event from wsock_events
if the call to WSASendTo fails with WSAEWOULDBLOCK. Fix return value
condition.
* select.cc (struct socketinf): Change to accomodate using socket event
handling.
(peek_socket): Use event handling for peeking socket.
(thread_socket): Ditto.
(start_thread_socket): Ditto.
(socket_cleanup): Same here.
* tlsoffsets.h: Regenerate.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Rearrange slightly to keep
event handling methods and members together. Drop owner status flag.
Split wait method. Rename event handling methods for readability.
* fhandler_socket.cc (struct wsa_event): Add owner field.
(LOCK_EVENTS): New macro.
(UNLOCK_EVENTS): Ditto.
(fhandler_socket::init_events): rename from prepare.
(fhandler_socket::evaluate_events): First half of former wait method.
Do everything but wait. Allow specifiying whether or not events from
event_mask should be erased from wsock_events->events. Simplify
OOB handling. Allow sending SIGURG to any process (group).
(fhandler_socket::wait_for_events): Second half of former wait method.
Call evaluate_events and wait in a loop if socket is blocking.
(fhandler_socket::release_events): Rename from release.
(fhandler_socket::connect): Accomodate above name changes.
(fhandler_socket::accept): Ditto.
(fhandler_socket::recv_internal): Ditto.
(fhandler_socket::send_internal): Ditto.
(fhandler_socket::close): Ditto.
(fhandler_socket::fcntl): Always set owner to given input value on
F_SETOWN. Handle F_GETOWN.
* net.cc (fdsock): Accomodate above name changes.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Set Winsock errno to
WSAEWOULDBLOCK instead of WSAEINPROGRESS.
2006-07-18 Brian Ford <Brian.Ford@FlightSafety.com>
Corinna Vinschen <corinna@vinschen.de>
* winsup.h (mmap_region_status): New enum.
(mmap_is_attached_or_noreserve_page): Adjust prototype and rename
as below.
* mmap.cc (mmap_is_attached_or_noreserve_page): Rename
mmap_is_attached_or_noreserve. Add region length parameter.
Return enum above.
* exceptions.cc (_cygtls::handle_exceptions): Accomodate above.
* fhandler.cc (fhandler_base::raw_read): Call above for NOACCESS
errors and retry on success to allow reads into untouched
MAP_NORESERVE buffers.
2006-07-18 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din (posix_openpt): Export.
* tty.cc (posix_openpt): New function.
* include/cygwin/stdlib.h (posix_openpt): Declare.
* include/cygwin/version.h: Bump API minor number.
2006-07-14 Corinna Vinschen <corinna@vinschen.de>
* security.cc (get_token_group_sidlist): Always add the interactive
group to the token. Add comment. Create logon_id group SID by
copying it from incoming group list.
(create_token): Add subauth_token parameter. Use information in
subauth_token if present. Tweak SourceIdentifier if subauth_token
is present for debugging purposes.
* security.h (create_token): Add subauth_token parameter in declaration.
* syscalls.cc (seteuid32): Call subauth first. Call create_token
regardless. Use subauth token in call to create_token if subauth
succeeded.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* include/netinet/in.h: Update copyright.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Rework function so that
WaitForMultipleObjects is really only called when necessary.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* include/netdb.h: Declare rcmd, rcmd_af, rexec, rresvport,
rresvport_af, iruserok, iruserok_sa, ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* Makefile.in (DLL_OFILES): Drop iruserok.o. Add rcmd.o.
* autoload.cc (rcmd): Drop definition.
* cygwin.din: Export bindresvport, bindresvport_sa, iruserok_sa,
rcmd_af, rresvport_af.
* net.cc (cygwin_rcmd): Remove.
(last_used_bindresvport): Rename from last_used_rrecvport.
(cygwin_bindresvport_sa): New function implementing bindresvport_sa.
(cygwin_bindresvport): New function implementing bindresvport.
(cygwin_rresvport): Remove.
* include/cygwin/version.h: Bump API minor number.
* include/netinet/in.h: Declare bindresvport and bindresvport_sa.
* libc/iruserok.c: Remove file.
* libc/rcmd.cc: New file implementing rcmd, rcmd_af, rresvport,
rresvport_af, iruserok_sa, iruserok and ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::getsockname): Return valid
result for unbound sockets.
2006-07-11 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::fixup_after_fork): Handle
wsock_mtx and wsock_evt on fork, thus handling close_on_exec correctly.
(fhandler_socket::fixup_after_exec): Drop misguided attempt to handle
close_on_exec here.
(fhandler_socket::dup): Call fixup_after_fork with NULL parent.
Add comment.
(fhandler_socket::set_close_on_exec): Handle wsock_mtx and wsock_evt.
2006-07-10 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Add wsock_mtx, wsock_evt
and wsock_events members. Remove closed status flag, add listener
status flag. Accomodate new implementation of socket event handling
methods. Declare recv* and send* functions ssize_t as the POSIX
equivalents.
(fhandler_socket::recv_internal): Declare.
(fhandler_socket::send_internal): Ditto.
* fhandler_socket.cc (EVENT_MASK): Define mask of selected events.
(fhandler_socket::fhandler_socket): Initialize new members.
(fhandler_socket::af_local_setblocking): Don't actually set the
socket to blocking mode. Keep sane event selection.
(fhandler_socket::af_local_unsetblocking): Don't actually set the
socket to previous blocking setting, just remember it.
(struct wsa_event): New structure to keep event data per shared
socket.
(NUM_SOCKS): Define number of shared sockets concurrently handled by
all active Cygwin processes.
(wsa_events): New shared datastructure keeping all wsa_event records.
(socket_serial_number): New shared variable to identify shared sockets.
(wsa_slot_mtx): Global mutex to serialize wsa_events access.
(search_wsa_event_slot): New static function to select a new wsa_event
slot for a new socket.
(fhandler_socket::prepare): Rewrite. Prepare event selection
per new socket.
(fhandler_socket::wait): Rewrite. Wait for socket events in thread
safe and multiple process safe.
(fhandler_socket::release): Rewrite. Close per-socket descriptor
mutex handle and event handle.
(fhandler_socket::dup): Duplicate wsock_mtx and wsock_evt. Fix
copy-paste error in debug output.
(fhandler_socket::connect): Accomodate new event handling.
(fhandler_socket::listen): Set listener flag on successful listen.
(fhandler_socket::accept): Accomodate new event handling.
(fhandler_socket::recv_internal): New inline method centralizing
common recv code.
(fhandler_socket::recvfrom): Call recv_internal now.
(fhandler_socket::recvmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::send_internal): New inline method centralizing
common send code.
(fhandler_socket::sendto): Call send_internal now.
(fhandler_socket::sendmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::close): Call release now.
(fhandler_socket::ioctl): Never actually switch to blocking mode.
Just keep track of the setting.
* net.cc (fdsock): Call prepare now.
(cygwin_connect): Revert again to event driven technique.
(cygwin_accept): Ditto.
* poll.cc (poll): Don't call recvfrom on a listening socket.
Remove special case for failing recvfrom.
* include/sys/socket.h: Declare recv* and send* functions ssize_t as
requested by POSIX.
2006-07-07 Corinna Vinschen <corinna@vinschen.de>
* net.cc (cygwin_inet_ntop): Fix data type of forth parameter.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/in6.h (struct in6_addr): Fix typo.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din: Export in6addr_any, in6addr_loopback, freeaddrinfo,
gai_strerror, getaddrinfo, getnameinfo.
* fhandler_socket.cc: Include cygwin/in6.h.
(get_inet_addr): Accomodate AF_INET6 usage.
(fhandler_socket::connect): Ditto.
(fhandler_socket::listen): Ditto.
(fhandler_socket::sendto): Ditto.
* net.cc: Include cygwin/in6.h.
(in6addr_any): Define.
(in6addr_loopback): Define.
(cygwin_socket): Accomodate AF_INET6 usage.
(socketpair): Bind socketpairs only to loopback for security.
(inet_pton4): New static function.
(inet_pton6): Ditto.
(cygwin_inet_pton): New AF_INET6 aware inet_pton implementation.
(inet_ntop4): New static function.
(inet_ntop6): Ditto.
(cygwin_inet_ntop): New AF_INET6 aware inet_ntop implementation.
(ga_aistruct): New static function.
(ga_clone): Ditto.
(ga_echeck): Ditto.
(ga_nsearch): Ditto.
(ga_port): Ditto.
(ga_serv): Ditto.
(ga_unix): Ditto.
(gn_ipv46): Ditto.
(ipv4_freeaddrinfo): Ditto.
(ipv4_getaddrinfo): Ditto.
(ipv4_getnameinfo): Ditto.
(gai_errmap_t): New structure holding error code - error string mapping.
(cygwin_gai_strerror): New function implementing gai_strerror.
(w32_to_gai_err): New static function.
(get_ipv6_funcs): Ditto.
(load_ipv6_funcs): Ditto.
(cygwin_freeaddrinfo): New function implementing freeaddrinfo.
(cygwin_getaddrinfo): New function implementing getaddrinfo.
(cygwin_getnameinfo): New function implementing getnameinfo.
* include/netdb.h: Include stdint.h and cygwin/socket.h. Define
data types and macros used by getaddrinfo and friends. Declare
freeaddrinfo, gai_strerror, getaddrinfo and getnameinfo.
* include/cygwin/in.h: Add IPv6 related IPPROTOs. Remove definition
of struct sockaddr_in6. Include cygwin/in6.h instead.
* include/cygwin/in6.h: New header file defining IPv6 releated
data types and macros.
* include/cygwin/socket.h: Enable AF_INET6 and PF_INET6. Add
IPv6 related socket options.
* include/cygwin/version.h: Bump API minor number.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* autoload.cc (DsGetDcNameA): Define.
(NetGetAnyDCName): Define.
* security.cc: Include dsgetdc.h.
(DsGetDcNameA): Declare.
(DS_FORCE_REDISCOVERY): Define.
(get_logon_server): Add bool parameter to control rediscovery of DC.
Use DsGetDcNameA function if supported, NetGetDCName/NetGetAnyDCName
otherwise.
(get_server_groups): Rediscover DC if get_user_groups fails and
try again.
(get_reg_security): Use correct error code macro when testing
RegGetKeySecurity return value.
* security.h (get_logon_server): Remove default vaue from wserver
parameter. Add rediscovery parameter.
* uinfo.cc (cygheap_user::env_logsrv): Accomodate rediscovery parameter
in call to get_logon_server.
2006-07-26 03:23:23 +08:00
|
|
|
case MMAP_RAISE_SIGBUS: /* MAP_NORESERVE page, commit failed, or
|
|
|
|
access to mmap page beyond EOF. */
|
2005-12-07 19:16:47 +08:00
|
|
|
si.si_signo = SIGBUS;
|
|
|
|
si.si_code = BUS_OBJERR;
|
2006-07-13 16:33:34 +08:00
|
|
|
break;
|
|
|
|
default:
|
2005-12-28 04:07:59 +08:00
|
|
|
MEMORY_BASIC_INFORMATION m;
|
|
|
|
VirtualQuery ((PVOID) e->ExceptionInformation[1], &m, sizeof m);
|
|
|
|
si.si_signo = SIGSEGV;
|
|
|
|
si.si_code = m.State == MEM_FREE ? SEGV_MAPERR : SEGV_ACCERR;
|
2006-07-13 16:33:34 +08:00
|
|
|
break;
|
2005-12-28 04:07:59 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
case STATUS_ARRAY_BOUNDS_EXCEEDED:
|
|
|
|
case STATUS_IN_PAGE_ERROR:
|
|
|
|
case STATUS_NO_MEMORY:
|
|
|
|
case STATUS_INVALID_DISPOSITION:
|
|
|
|
case STATUS_STACK_OVERFLOW:
|
2004-01-19 13:46:54 +08:00
|
|
|
si.si_signo = SIGSEGV;
|
2005-09-26 21:23:47 +08:00
|
|
|
si.si_code = SEGV_MAPERR;
|
2000-02-18 03:38:33 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case STATUS_CONTROL_C_EXIT:
|
2004-01-19 13:46:54 +08:00
|
|
|
si.si_signo = SIGINT;
|
2000-02-18 03:38:33 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case STATUS_INVALID_HANDLE:
|
|
|
|
/* CloseHandle will throw this exception if it is given an
|
|
|
|
invalid handle. We don't care about the exception; we just
|
|
|
|
want CloseHandle to return an error. This can be revisited
|
|
|
|
if gcc ever supports Windows style structured exception
|
|
|
|
handling. */
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* If we don't recognize the exception, we have to assume that
|
|
|
|
we are doing structured exception handling, and we let
|
|
|
|
something else handle it. */
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2011-12-05 01:58:24 +08:00
|
|
|
debug_printf ("In cygwin_except_handler exception %p at %p sp %p", e->ExceptionCode, in->Eip, in->Esp);
|
2011-11-14 09:29:49 +08:00
|
|
|
debug_printf ("In cygwin_except_handler signal %d at %p", si.si_signo, in->Eip);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2008-03-03 06:51:19 +08:00
|
|
|
bool masked = !!(me.sigmask & SIGTOMASK (si.si_signo));
|
|
|
|
if (masked)
|
2004-01-19 13:46:54 +08:00
|
|
|
syscall_printf ("signal %d, masked %p", si.si_signo,
|
|
|
|
global_sigs[si.si_signo].sa_mask);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2000-07-04 04:14:06 +08:00
|
|
|
debug_printf ("In cygwin_except_handler calling %p",
|
2004-01-19 13:46:54 +08:00
|
|
|
global_sigs[si.si_signo].sa_handler);
|
2000-07-04 04:14:06 +08:00
|
|
|
|
2005-12-03 12:23:35 +08:00
|
|
|
DWORD *ebp = (DWORD *) in->Esp;
|
2000-07-04 04:14:06 +08:00
|
|
|
for (DWORD *bpend = (DWORD *) __builtin_frame_address (0); ebp > bpend; ebp--)
|
2005-12-03 12:23:35 +08:00
|
|
|
if (*ebp == in->SegCs && ebp[-1] == in->Eip)
|
2000-07-04 04:14:06 +08:00
|
|
|
{
|
|
|
|
ebp -= 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-02-27 05:36:31 +08:00
|
|
|
if (me.andreas)
|
|
|
|
me.andreas->leave (); /* Return from a "san" caught fault */
|
2006-02-07 02:24:11 +08:00
|
|
|
|
|
|
|
me.copy_context (in);
|
2008-03-03 06:51:19 +08:00
|
|
|
|
2008-03-12 20:41:50 +08:00
|
|
|
/* Temporarily replace windows top level SEH with our own handler.
|
|
|
|
We don't want any Windows magic kicking in. This top level frame
|
|
|
|
will be removed automatically after our exception handler returns. */
|
2010-02-28 23:54:25 +08:00
|
|
|
_except_list->handler = handle;
|
2008-03-03 06:51:19 +08:00
|
|
|
|
|
|
|
if (masked
|
2006-02-07 02:24:11 +08:00
|
|
|
|| &me == _sig_tls
|
2008-03-03 06:51:19 +08:00
|
|
|
|| !cygwin_finished_initializing
|
2006-02-07 02:24:11 +08:00
|
|
|
|| (void *) global_sigs[si.si_signo].sa_handler == (void *) SIG_DFL
|
|
|
|
|| (void *) global_sigs[si.si_signo].sa_handler == (void *) SIG_IGN
|
|
|
|
|| (void *) global_sigs[si.si_signo].sa_handler == (void *) SIG_ERR)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
/* Print the exception to the console */
|
2004-11-26 12:15:10 +08:00
|
|
|
if (!myself->cygstarted)
|
2004-03-12 10:07:39 +08:00
|
|
|
for (int i = 0; status_info[i].name; i++)
|
2005-12-03 12:23:35 +08:00
|
|
|
if (status_info[i].code == e->ExceptionCode)
|
2004-03-12 10:07:39 +08:00
|
|
|
{
|
2004-01-19 13:46:54 +08:00
|
|
|
system_printf ("Exception: %s", status_info[i].name);
|
2004-03-12 10:07:39 +08:00
|
|
|
break;
|
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
/* Another exception could happen while tracing or while exiting.
|
|
|
|
Only do this once. */
|
2001-04-30 11:09:19 +08:00
|
|
|
if (recursed++)
|
2000-07-05 03:07:35 +08:00
|
|
|
system_printf ("Error while dumping state (probably corrupted stack)");
|
2000-02-18 03:38:33 +08:00
|
|
|
else
|
|
|
|
{
|
2001-04-30 11:09:19 +08:00
|
|
|
if (try_to_debug (0))
|
|
|
|
{
|
2003-11-29 04:55:59 +08:00
|
|
|
debugging = true;
|
2008-03-03 06:51:19 +08:00
|
|
|
return 0;
|
2001-04-30 11:09:19 +08:00
|
|
|
}
|
|
|
|
|
2008-03-12 20:41:50 +08:00
|
|
|
rtl_unwind (frame, e);
|
2010-04-20 18:44:52 +08:00
|
|
|
if (cygheap->rlim_core > 0UL)
|
|
|
|
{
|
|
|
|
open_stackdumpfile ();
|
|
|
|
dump_exception (e, in);
|
|
|
|
stackdump ((DWORD) ebp, 0, 1);
|
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
2001-04-30 11:09:19 +08:00
|
|
|
|
2005-12-28 04:07:59 +08:00
|
|
|
if (e->ExceptionCode == STATUS_ACCESS_VIOLATION)
|
2006-02-07 02:24:11 +08:00
|
|
|
{
|
2005-12-28 04:07:59 +08:00
|
|
|
int error_code = 0;
|
|
|
|
if (si.si_code == SEGV_ACCERR) /* Address present */
|
|
|
|
error_code |= 1;
|
|
|
|
if (e->ExceptionInformation[0]) /* Write access */
|
|
|
|
error_code |= 2;
|
2007-07-29 13:22:05 +08:00
|
|
|
if (!me.inside_kernel (in)) /* User space */
|
2005-12-28 04:07:59 +08:00
|
|
|
error_code |= 4;
|
|
|
|
klog (LOG_INFO, "%s[%d]: segfault at %08x rip %08x rsp %08x error %d",
|
|
|
|
__progname, myself->pid,
|
|
|
|
e->ExceptionInformation[1], in->Eip, in->Esp,
|
|
|
|
((in->Eip >= 0x61000000 && in->Eip < 0x61200000)
|
|
|
|
? 0 : 4) | (e->ExceptionInformation[0] << 1));
|
|
|
|
}
|
|
|
|
|
2010-04-20 18:44:52 +08:00
|
|
|
/* Flag signal + core dump */
|
|
|
|
me.signal_exit ((cygheap->rlim_core > 0UL ? 0x80 : 0) | si.si_signo);
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
|
2009-07-23 10:47:17 +08:00
|
|
|
si.si_addr = (si.si_signo == SIGSEGV || si.si_signo == SIGBUS
|
2011-06-06 13:02:13 +08:00
|
|
|
? (void *) e->ExceptionInformation[1]
|
|
|
|
: (void *) in->Eip);
|
2004-01-19 13:46:54 +08:00
|
|
|
si.si_errno = si.si_pid = si.si_uid = 0;
|
2005-12-06 04:20:18 +08:00
|
|
|
me.incyg++;
|
2005-07-03 10:40:30 +08:00
|
|
|
sig_send (NULL, si, &me); // Signal myself
|
2005-12-06 04:20:18 +08:00
|
|
|
me.incyg--;
|
2005-12-03 12:23:35 +08:00
|
|
|
e->ExceptionFlags = 0;
|
2008-03-01 21:18:22 +08:00
|
|
|
return 0;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Utilities to call a user supplied exception handler. */
|
|
|
|
|
2001-01-08 12:02:02 +08:00
|
|
|
#define SIG_NONMASKABLE (SIGTOMASK (SIGKILL) | SIGTOMASK (SIGSTOP))
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
/* Non-raceable sigsuspend
|
|
|
|
* Note: This implementation is based on the Single UNIX Specification
|
|
|
|
* man page. This indicates that sigsuspend always returns -1 and that
|
|
|
|
* attempts to block unblockable signals will be silently ignored.
|
|
|
|
* This is counter to what appears to be documented in some UNIX
|
|
|
|
* man pages, e.g. Linux.
|
|
|
|
*/
|
|
|
|
int __stdcall
|
|
|
|
handle_sigsuspend (sigset_t tempmask)
|
|
|
|
{
|
2008-02-16 01:53:11 +08:00
|
|
|
sigset_t oldmask = _my_tls.sigmask; // Remember for restoration
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2008-02-16 01:53:11 +08:00
|
|
|
set_signal_mask (tempmask, _my_tls.sigmask);
|
2003-12-24 00:26:31 +08:00
|
|
|
sigproc_printf ("oldmask %p, newmask %p", oldmask, tempmask);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2003-01-15 03:55:42 +08:00
|
|
|
pthread_testcancel ();
|
2011-08-04 00:40:48 +08:00
|
|
|
cancelable_wait (signal_arrived);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
set_sig_errno (EINTR); // Per POSIX
|
|
|
|
|
|
|
|
/* A signal dispatch function will have been added to our stack and will
|
|
|
|
be hit eventually. Set the old mask to be restored when the signal
|
2004-03-12 11:09:28 +08:00
|
|
|
handler returns and indicate its presence by modifying deltamask. */
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2004-03-12 11:09:28 +08:00
|
|
|
_my_tls.deltamask |= SIG_NONMASKABLE;
|
2003-11-29 04:55:59 +08:00
|
|
|
_my_tls.oldmask = oldmask; // Will be restored by signal handler
|
2000-02-18 03:38:33 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern DWORD exec_exit; // Possible exit value for exec
|
|
|
|
|
2001-01-17 22:57:09 +08:00
|
|
|
extern "C" {
|
|
|
|
static void
|
|
|
|
sig_handle_tty_stop (int sig)
|
|
|
|
{
|
2004-09-20 13:35:46 +08:00
|
|
|
_my_tls.incyg = 1;
|
2004-09-20 12:58:36 +08:00
|
|
|
/* Silently ignore attempts to suspend if there is no accommodating
|
2001-03-02 10:09:40 +08:00
|
|
|
cygwin parent to deal with this behavior. */
|
2004-11-26 12:15:10 +08:00
|
|
|
if (!myself->cygstarted)
|
2001-06-17 01:09:19 +08:00
|
|
|
{
|
|
|
|
myself->process_state &= ~PID_STOPPED;
|
|
|
|
return;
|
|
|
|
}
|
2002-01-20 07:57:45 +08:00
|
|
|
|
2001-01-17 22:57:09 +08:00
|
|
|
myself->stopsig = sig;
|
2004-12-25 02:31:23 +08:00
|
|
|
myself->alert_parent (sig);
|
2004-11-26 12:15:10 +08:00
|
|
|
sigproc_printf ("process %d stopped by signal %d", myself->pid, sig);
|
2004-01-27 06:25:57 +08:00
|
|
|
HANDLE w4[2];
|
|
|
|
w4[0] = sigCONT;
|
|
|
|
w4[1] = signal_arrived;
|
|
|
|
switch (WaitForMultipleObjects (2, w4, TRUE, INFINITE))
|
|
|
|
{
|
|
|
|
case WAIT_OBJECT_0:
|
|
|
|
case WAIT_OBJECT_0 + 1:
|
2009-07-19 04:25:07 +08:00
|
|
|
myself->stopsig = SIGCONT;
|
2004-12-25 02:31:23 +08:00
|
|
|
myself->alert_parent (SIGCONT);
|
2004-01-27 06:25:57 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
api_fatal ("WaitSingleObject failed, %E");
|
|
|
|
break;
|
|
|
|
}
|
2004-09-20 12:58:36 +08:00
|
|
|
_my_tls.incyg = 0;
|
2001-01-17 22:57:09 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-14 23:45:37 +08:00
|
|
|
bool
|
2005-12-20 08:31:50 +08:00
|
|
|
_cygtls::interrupt_now (CONTEXT *cx, int sig, void *handler,
|
|
|
|
struct sigaction& siga)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2005-12-20 08:31:50 +08:00
|
|
|
bool interrupted;
|
|
|
|
|
2010-08-02 03:10:52 +08:00
|
|
|
/* Delay the interrupt if we are
|
|
|
|
1) somehow inside the DLL
|
2011-07-07 02:44:06 +08:00
|
|
|
2) in _sigfe (spinning is true) and about to enter cygwin DLL
|
|
|
|
3) in a Windows DLL. */
|
|
|
|
if (incyg || spinning || inside_kernel (cx))
|
2005-12-20 08:31:50 +08:00
|
|
|
interrupted = false;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
push ((__stack_t) cx->Eip);
|
|
|
|
interrupt_setup (sig, handler, siga);
|
|
|
|
cx->Eip = pop ();
|
|
|
|
SetThreadContext (*this, cx); /* Restart the thread in a new location */
|
|
|
|
interrupted = true;
|
|
|
|
}
|
|
|
|
return interrupted;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
2005-12-20 08:31:50 +08:00
|
|
|
|
2003-11-29 04:55:59 +08:00
|
|
|
void __stdcall
|
2004-03-12 10:07:39 +08:00
|
|
|
_cygtls::interrupt_setup (int sig, void *handler, struct sigaction& siga)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2005-12-06 04:20:18 +08:00
|
|
|
push ((__stack_t) sigdelayed);
|
2005-12-24 06:50:20 +08:00
|
|
|
deltamask = siga.sa_mask & ~SIG_NONMASKABLE;
|
2003-11-29 04:55:59 +08:00
|
|
|
sa_flags = siga.sa_flags;
|
|
|
|
func = (void (*) (int)) handler;
|
2006-01-02 00:51:29 +08:00
|
|
|
if (siga.sa_flags & SA_RESETHAND)
|
|
|
|
siga.sa_handler = SIG_DFL;
|
2003-11-29 04:55:59 +08:00
|
|
|
saved_errno = -1; // Flag: no errno to save
|
2001-01-17 22:57:09 +08:00
|
|
|
if (handler == sig_handle_tty_stop)
|
|
|
|
{
|
|
|
|
myself->stopsig = 0;
|
|
|
|
myself->process_state |= PID_STOPPED;
|
|
|
|
}
|
2004-02-09 12:04:24 +08:00
|
|
|
|
2004-02-22 06:57:36 +08:00
|
|
|
this->sig = sig; // Should always be last thing set to avoid a race
|
2004-02-09 12:04:24 +08:00
|
|
|
|
2006-02-07 02:24:11 +08:00
|
|
|
if (!event)
|
|
|
|
threadkill = false;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
HANDLE h = event;
|
|
|
|
event = NULL;
|
|
|
|
SetEvent (h);
|
|
|
|
}
|
|
|
|
|
2001-06-25 05:57:50 +08:00
|
|
|
/* Clear any waiting threads prior to dispatching to handler function */
|
|
|
|
int res = SetEvent (signal_arrived); // For an EINTR case
|
2003-11-29 04:55:59 +08:00
|
|
|
proc_subproc (PROC_CLEARWAIT, 1);
|
2011-11-14 09:29:49 +08:00
|
|
|
sigproc_printf ("armed signal_arrived %p, signal %d, res %d", signal_arrived,
|
2004-01-14 23:45:37 +08:00
|
|
|
sig, res);
|
2000-02-28 13:05:33 +08:00
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
extern "C" void __stdcall
|
|
|
|
set_sig_errno (int e)
|
|
|
|
{
|
2003-12-18 06:47:32 +08:00
|
|
|
*_my_tls.errno_addr = e;
|
2003-11-29 04:55:59 +08:00
|
|
|
_my_tls.saved_errno = e;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
|
2004-02-12 11:01:58 +08:00
|
|
|
static int setup_handler (int, void *, struct sigaction&, _cygtls *tls)
|
2003-11-29 04:55:59 +08:00
|
|
|
__attribute__((regparm(3)));
|
2000-02-18 03:38:33 +08:00
|
|
|
static int
|
2004-02-12 11:01:58 +08:00
|
|
|
setup_handler (int sig, void *handler, struct sigaction& siga, _cygtls *tls)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2000-03-10 05:04:05 +08:00
|
|
|
CONTEXT cx;
|
2002-11-22 12:43:47 +08:00
|
|
|
bool interrupted = false;
|
2000-05-17 13:49:51 +08:00
|
|
|
|
2003-11-29 04:55:59 +08:00
|
|
|
if (tls->sig)
|
2004-01-23 03:03:19 +08:00
|
|
|
{
|
2011-11-14 09:29:49 +08:00
|
|
|
sigproc_printf ("trying to send signal %d but signal %d already armed",
|
2004-01-23 03:03:19 +08:00
|
|
|
sig, tls->sig);
|
|
|
|
goto out;
|
|
|
|
}
|
2000-10-18 12:53:37 +08:00
|
|
|
|
2011-07-07 00:33:30 +08:00
|
|
|
for (int n = 0; n < CALL_HANDLER_RETRY_OUTER; n++)
|
2000-05-20 13:52:33 +08:00
|
|
|
{
|
2011-07-07 00:33:30 +08:00
|
|
|
for (int i = 0; i < CALL_HANDLER_RETRY_INNER; i++)
|
2002-11-22 12:43:47 +08:00
|
|
|
{
|
2011-07-07 00:33:30 +08:00
|
|
|
tls->lock ();
|
|
|
|
if (tls->incyg)
|
|
|
|
{
|
|
|
|
sigproc_printf ("controlled interrupt. stackptr %p, stack %p, stackptr[-1] %p",
|
|
|
|
tls->stackptr, tls->stack, tls->stackptr[-1]);
|
|
|
|
tls->interrupt_setup (sig, handler, siga);
|
|
|
|
interrupted = true;
|
|
|
|
tls->unlock ();
|
2011-07-14 01:53:21 +08:00
|
|
|
goto out;
|
2011-07-07 00:33:30 +08:00
|
|
|
}
|
2000-11-07 07:12:05 +08:00
|
|
|
|
2011-07-07 00:33:30 +08:00
|
|
|
DWORD res;
|
|
|
|
HANDLE hth = (HANDLE) *tls;
|
2002-11-22 12:43:47 +08:00
|
|
|
|
2011-07-07 00:33:30 +08:00
|
|
|
/* Suspend the thread which will receive the signal.
|
|
|
|
If one of these conditions is not true we loop.
|
|
|
|
If the thread is already suspended (which can occur when a program
|
|
|
|
has called SuspendThread on itself) then just queue the signal. */
|
2004-01-14 23:45:37 +08:00
|
|
|
|
2011-07-07 00:33:30 +08:00
|
|
|
sigproc_printf ("suspending thread");
|
|
|
|
res = SuspendThread (hth);
|
|
|
|
/* Just set pending if thread is already suspended */
|
|
|
|
if (res)
|
|
|
|
{
|
|
|
|
ResumeThread (hth);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
cx.ContextFlags = CONTEXT_CONTROL | CONTEXT_INTEGER;
|
|
|
|
if (!GetThreadContext (hth, &cx))
|
|
|
|
system_printf ("couldn't get context of thread, %E");
|
2011-07-07 02:14:22 +08:00
|
|
|
else
|
2011-07-07 02:44:06 +08:00
|
|
|
interrupted = tls->interrupt_now (&cx, sig, handler, siga);
|
2011-07-07 00:33:30 +08:00
|
|
|
|
|
|
|
tls->unlock ();
|
|
|
|
res = ResumeThread (hth);
|
|
|
|
if (interrupted)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
sigproc_printf ("couldn't interrupt. trying again.");
|
|
|
|
yield ();
|
|
|
|
}
|
|
|
|
/* Hit here if we couldn't deliver the signal. Take a more drastic
|
|
|
|
action before trying again. */
|
|
|
|
Sleep (1);
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
|
2003-08-28 10:04:16 +08:00
|
|
|
out:
|
|
|
|
sigproc_printf ("signal %d %sdelivered", sig, interrupted ? "" : "not ");
|
2000-02-24 10:49:44 +08:00
|
|
|
return interrupted;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
|
* wininfo.h (wininfo::timer_active): Delete.
(wininfo::itv): Ditto.
(wininfo::start_time): Ditto.
(wininfo::window_started): Ditto.
(wininfo::getitimer): Ditto.
(wininfo::setitimer): Ditto.
(wininfo::wininfo): Ditto.
(wininfo::lock): New method.
(wininfo::release): Ditto.
* window.cc: Use new lock/acquire wininfo methods throughout.
(wininfo::wininfo): Delete
(wininfo::getitimer): Ditto.
(wininfo::setitimer): Ditto.
(getitimer): Ditto.
(setitimer): Ditto.
(ualarm): Ditto.
(alarm): Ditto.
(wininfo::lock): Define new function.
(wininfo::release): Ditto.
(wininfo::process): Delete WM_TIMER handling.
* timer.cc (struct timetracker): Delete it, flags. Add it_interval,
interval_us, sleepto_us, running, init_muto(), syncthread, and gettime().
(ttstart): Make NO_COPY.
(lock_timer_tracker): New class.
(timer_tracker::timer_tracker): Distinguish ttstart case.
(timer_tracker::~timer_tracker): New destructor. Clean out events, and reset
magic.
(timer_tracker::init_muto): New method.
(to_us): Round up as per POSIX.
(timer_thread): Reorganize to match timer_tracker::settime and
timer_tracker::gettime. Call sig_send without wait. Call auto_release.
(timer_tracker::settime): Reorganize logic to avoid race. Call gettime to
recover old value.
(timer_tracker::gettime): New method.
(timer_create): Properly set errno on invalid timerid. Use new
lock_timer_tracker method.
(timer_delete): Ditto. Simplify code slightly.
(timer_gettime): New function.
(fixup_timers_after_fork): Reinit ttstart.
(getitimer): New implementation.
(setitimer): Ditto.
(ualarm): Ditto.
(alarm): Ditto.
* cygwin.din: Export timer_gettime.
* winsup.h: Remove has has_visible_window_station declaration.
* Makefile.in (DLL_OFILES): Add lsearch.o.
* cygthread.h (cygthread::notify_detached): New element.
(cygthread::cygthread): Take optional fourth argument signifying event to
signal on thread completion.
* cygthread.cc (cygthread::stub): Signal notify_detached event, if it exists.
(cygthread::cygthread): Initialize notify_detached from fourth argument.
(cygthread::detach): Wait for notify_detached field is present.
* lsearch.cc: New file.
* search.h: Ditto.
* include/cygwin/version.h: Bump API minor number to 126.
* cygwin.din: Export lsearch, lfind.
2005-03-27 09:57:38 +08:00
|
|
|
static inline bool
|
|
|
|
has_visible_window_station ()
|
|
|
|
{
|
|
|
|
HWINSTA station_hdl;
|
|
|
|
USEROBJECTFLAGS uof;
|
|
|
|
DWORD len;
|
|
|
|
|
|
|
|
/* Check if the process is associated with a visible window station.
|
|
|
|
These are processes running on the local desktop as well as processes
|
|
|
|
running in terminal server sessions.
|
|
|
|
Processes running in a service session not explicitely associated
|
|
|
|
with the desktop (using the "Allow service to interact with desktop"
|
|
|
|
property) are running in an invisible window station. */
|
|
|
|
if ((station_hdl = GetProcessWindowStation ())
|
2008-04-03 23:28:03 +08:00
|
|
|
&& GetUserObjectInformationW (station_hdl, UOI_FLAGS, &uof,
|
* wininfo.h (wininfo::timer_active): Delete.
(wininfo::itv): Ditto.
(wininfo::start_time): Ditto.
(wininfo::window_started): Ditto.
(wininfo::getitimer): Ditto.
(wininfo::setitimer): Ditto.
(wininfo::wininfo): Ditto.
(wininfo::lock): New method.
(wininfo::release): Ditto.
* window.cc: Use new lock/acquire wininfo methods throughout.
(wininfo::wininfo): Delete
(wininfo::getitimer): Ditto.
(wininfo::setitimer): Ditto.
(getitimer): Ditto.
(setitimer): Ditto.
(ualarm): Ditto.
(alarm): Ditto.
(wininfo::lock): Define new function.
(wininfo::release): Ditto.
(wininfo::process): Delete WM_TIMER handling.
* timer.cc (struct timetracker): Delete it, flags. Add it_interval,
interval_us, sleepto_us, running, init_muto(), syncthread, and gettime().
(ttstart): Make NO_COPY.
(lock_timer_tracker): New class.
(timer_tracker::timer_tracker): Distinguish ttstart case.
(timer_tracker::~timer_tracker): New destructor. Clean out events, and reset
magic.
(timer_tracker::init_muto): New method.
(to_us): Round up as per POSIX.
(timer_thread): Reorganize to match timer_tracker::settime and
timer_tracker::gettime. Call sig_send without wait. Call auto_release.
(timer_tracker::settime): Reorganize logic to avoid race. Call gettime to
recover old value.
(timer_tracker::gettime): New method.
(timer_create): Properly set errno on invalid timerid. Use new
lock_timer_tracker method.
(timer_delete): Ditto. Simplify code slightly.
(timer_gettime): New function.
(fixup_timers_after_fork): Reinit ttstart.
(getitimer): New implementation.
(setitimer): Ditto.
(ualarm): Ditto.
(alarm): Ditto.
* cygwin.din: Export timer_gettime.
* winsup.h: Remove has has_visible_window_station declaration.
* Makefile.in (DLL_OFILES): Add lsearch.o.
* cygthread.h (cygthread::notify_detached): New element.
(cygthread::cygthread): Take optional fourth argument signifying event to
signal on thread completion.
* cygthread.cc (cygthread::stub): Signal notify_detached event, if it exists.
(cygthread::cygthread): Initialize notify_detached from fourth argument.
(cygthread::detach): Wait for notify_detached field is present.
* lsearch.cc: New file.
* search.h: Ditto.
* include/cygwin/version.h: Bump API minor number to 126.
* cygwin.din: Export lsearch, lfind.
2005-03-27 09:57:38 +08:00
|
|
|
sizeof uof, &len)
|
|
|
|
&& (uof.dwFlags & WSF_VISIBLE))
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2002-01-11 10:24:06 +08:00
|
|
|
/* Keyboard interrupt handler. */
|
2000-02-18 03:38:33 +08:00
|
|
|
static BOOL WINAPI
|
|
|
|
ctrl_c_handler (DWORD type)
|
|
|
|
{
|
2003-07-26 12:53:59 +08:00
|
|
|
static bool saw_close;
|
2004-02-12 11:01:58 +08:00
|
|
|
|
|
|
|
if (!cygwin_finished_initializing)
|
2004-02-14 12:38:37 +08:00
|
|
|
{
|
2004-11-26 12:15:10 +08:00
|
|
|
if (myself->cygstarted) /* Was this process created by a cygwin process? */
|
2004-09-12 11:47:57 +08:00
|
|
|
return TRUE; /* Yes. Let the parent eventually handle CTRL-C issues. */
|
2004-02-14 12:38:37 +08:00
|
|
|
debug_printf ("exiting with status %p", STATUS_CONTROL_C_EXIT);
|
|
|
|
ExitProcess (STATUS_CONTROL_C_EXIT);
|
|
|
|
}
|
2004-02-12 11:01:58 +08:00
|
|
|
|
2011-12-10 09:33:56 +08:00
|
|
|
/* Remove early or we could overthrow the threadlist in cygheap.
|
|
|
|
Deleting this line causes ash to SEGV if CTRL-C is hit repeatedly.
|
|
|
|
I am not exactly sure why that is. Maybe it's just because this
|
|
|
|
adds some early serialization to ctrl_c_handler which prevents
|
|
|
|
multiple simultaneous calls? */
|
|
|
|
_my_tls.remove (INFINITE);
|
|
|
|
|
2005-09-07 11:10:17 +08:00
|
|
|
#if 0
|
|
|
|
if (type == CTRL_C_EVENT || type == CTRL_BREAK_EVENT)
|
|
|
|
proc_subproc (PROC_KILLFORKED, 0);
|
|
|
|
#endif
|
|
|
|
|
2001-07-26 08:10:52 +08:00
|
|
|
/* Return FALSE to prevent an "End task" dialog box from appearing
|
|
|
|
for each Cygwin process window that's open when the computer
|
|
|
|
is shut down or console window is closed. */
|
2003-07-26 12:53:59 +08:00
|
|
|
|
2001-07-26 08:10:52 +08:00
|
|
|
if (type == CTRL_SHUTDOWN_EVENT)
|
|
|
|
{
|
2003-06-12 20:36:07 +08:00
|
|
|
#if 0
|
|
|
|
/* Don't send a signal. Only NT service applications and their child
|
2003-07-26 12:53:59 +08:00
|
|
|
processes will receive this event and the services typically already
|
2003-06-12 20:36:07 +08:00
|
|
|
handle the shutdown action when getting the SERVICE_CONTROL_SHUTDOWN
|
|
|
|
control message. */
|
2001-07-26 08:10:52 +08:00
|
|
|
sig_send (NULL, SIGTERM);
|
2003-06-12 20:36:07 +08:00
|
|
|
#endif
|
2001-07-26 08:10:52 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
2003-07-26 12:53:59 +08:00
|
|
|
|
2003-10-14 17:21:55 +08:00
|
|
|
if (myself->ctty != -1)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2003-07-26 12:53:59 +08:00
|
|
|
if (type == CTRL_CLOSE_EVENT)
|
2004-05-29 03:50:07 +08:00
|
|
|
{
|
2003-10-14 17:21:55 +08:00
|
|
|
sig_send (NULL, SIGHUP);
|
2004-01-19 13:46:54 +08:00
|
|
|
saw_close = true;
|
2003-10-14 17:21:55 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!saw_close && type == CTRL_LOGOFF_EVENT)
|
2004-05-29 03:50:07 +08:00
|
|
|
{
|
2006-04-19 00:24:54 +08:00
|
|
|
/* The CTRL_LOGOFF_EVENT is sent when *any* user logs off.
|
|
|
|
The below code sends a SIGHUP only if it is not performing the
|
|
|
|
default activity for SIGHUP. Note that it is possible for two
|
|
|
|
SIGHUP signals to arrive if a process group leader is exiting
|
|
|
|
too. Getting this 100% right is saved for a future cygwin mailing
|
|
|
|
list goad. */
|
|
|
|
if (global_sigs[SIGHUP].sa_handler != SIG_DFL)
|
|
|
|
{
|
|
|
|
sig_send (myself_nowait, SIGHUP);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
2003-10-14 17:21:55 +08:00
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
2001-07-26 08:10:52 +08:00
|
|
|
|
2011-11-14 09:29:49 +08:00
|
|
|
if (ch_spawn.set_saw_ctrl_c ())
|
|
|
|
return TRUE;
|
2002-01-10 11:21:27 +08:00
|
|
|
|
|
|
|
/* We're only the process group leader when we have a valid pinfo structure.
|
|
|
|
If we don't have one, then the parent "stub" will handle the signal. */
|
2002-01-21 07:13:03 +08:00
|
|
|
if (!pinfo (cygwin_pid (GetCurrentProcessId ())))
|
2002-01-10 11:21:27 +08:00
|
|
|
return TRUE;
|
|
|
|
|
2011-05-29 02:17:09 +08:00
|
|
|
tty_min *t = cygwin_shared->tty.get_cttyp ();
|
2002-01-10 11:21:27 +08:00
|
|
|
/* Ignore this if we're not the process group leader since it should be handled
|
2000-02-18 03:38:33 +08:00
|
|
|
*by* the process group leader. */
|
2011-06-01 09:47:51 +08:00
|
|
|
if (t && t->getpgid () == myself->pid &&
|
2001-09-05 10:42:49 +08:00
|
|
|
(GetTickCount () - t->last_ctrl_c) >= MIN_CTRL_C_SLOP)
|
2000-02-18 03:38:33 +08:00
|
|
|
/* Otherwise we just send a SIGINT to the process group and return TRUE (to indicate
|
|
|
|
that we have handled the signal). At this point, type should be
|
|
|
|
a CTRL_C_EVENT or CTRL_BREAK_EVENT. */
|
|
|
|
{
|
2005-11-26 03:53:52 +08:00
|
|
|
int sig = SIGINT;
|
|
|
|
/* If intr and quit are both mapped to ^C, send SIGQUIT on ^BREAK */
|
|
|
|
if (type == CTRL_BREAK_EVENT
|
2005-12-22 13:57:54 +08:00
|
|
|
&& t->ti.c_cc[VINTR] == 3 && t->ti.c_cc[VQUIT] == 3)
|
|
|
|
sig = SIGQUIT;
|
2000-02-18 03:38:33 +08:00
|
|
|
t->last_ctrl_c = GetTickCount ();
|
2005-11-26 03:53:52 +08:00
|
|
|
killsys (-myself->pid, sig);
|
2000-02-18 03:38:33 +08:00
|
|
|
t->last_ctrl_c = GetTickCount ();
|
|
|
|
return TRUE;
|
|
|
|
}
|
2002-01-10 11:21:27 +08:00
|
|
|
|
2001-09-05 10:42:49 +08:00
|
|
|
return TRUE;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
|
2003-11-29 04:55:59 +08:00
|
|
|
/* Function used by low level sig wrappers. */
|
|
|
|
extern "C" void __stdcall
|
|
|
|
set_process_mask (sigset_t newmask)
|
|
|
|
{
|
2008-02-16 01:53:11 +08:00
|
|
|
set_signal_mask (newmask, _my_tls.sigmask);
|
2003-11-29 04:55:59 +08:00
|
|
|
}
|
|
|
|
|
2004-02-26 13:10:49 +08:00
|
|
|
extern "C" int
|
|
|
|
sighold (int sig)
|
|
|
|
{
|
|
|
|
/* check that sig is in right range */
|
|
|
|
if (sig < 0 || sig >= NSIG)
|
|
|
|
{
|
|
|
|
set_errno (EINVAL);
|
|
|
|
syscall_printf ("signal %d out of range", sig);
|
|
|
|
return -1;
|
|
|
|
}
|
2005-04-05 12:31:00 +08:00
|
|
|
mask_sync.acquire (INFINITE);
|
2008-02-16 01:53:11 +08:00
|
|
|
sigset_t mask = _my_tls.sigmask;
|
2004-02-26 13:10:49 +08:00
|
|
|
sigaddset (&mask, sig);
|
2008-02-16 01:53:11 +08:00
|
|
|
set_signal_mask (mask, _my_tls.sigmask);
|
2005-04-05 12:31:00 +08:00
|
|
|
mask_sync.release ();
|
2004-02-26 13:10:49 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-04-15 01:34:03 +08:00
|
|
|
extern "C" int
|
|
|
|
sigrelse (int sig)
|
|
|
|
{
|
|
|
|
/* check that sig is in right range */
|
|
|
|
if (sig < 0 || sig >= NSIG)
|
|
|
|
{
|
|
|
|
set_errno (EINVAL);
|
|
|
|
syscall_printf ("signal %d out of range", sig);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
mask_sync.acquire (INFINITE);
|
2008-02-16 01:53:11 +08:00
|
|
|
sigset_t mask = _my_tls.sigmask;
|
2005-04-15 01:34:03 +08:00
|
|
|
sigdelset (&mask, sig);
|
2008-02-16 01:53:11 +08:00
|
|
|
set_signal_mask (mask, _my_tls.sigmask);
|
2005-04-15 01:34:03 +08:00
|
|
|
mask_sync.release ();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-02-17 02:21:49 +08:00
|
|
|
extern "C" _sig_func_ptr
|
|
|
|
sigset (int sig, _sig_func_ptr func)
|
|
|
|
{
|
|
|
|
sig_dispatch_pending ();
|
|
|
|
_sig_func_ptr prev;
|
|
|
|
|
|
|
|
/* check that sig is in right range */
|
|
|
|
if (sig < 0 || sig >= NSIG || sig == SIGKILL || sig == SIGSTOP)
|
|
|
|
{
|
|
|
|
set_errno (EINVAL);
|
|
|
|
syscall_printf ("SIG_ERR = sigset (%d, %p)", sig, func);
|
|
|
|
return (_sig_func_ptr) SIG_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
mask_sync.acquire (INFINITE);
|
2008-02-16 01:53:11 +08:00
|
|
|
sigset_t mask = _my_tls.sigmask;
|
2006-02-17 02:21:49 +08:00
|
|
|
/* If sig was in the signal mask return SIG_HOLD, otherwise return the
|
|
|
|
previous disposition. */
|
|
|
|
if (sigismember (&mask, sig))
|
|
|
|
prev = SIG_HOLD;
|
|
|
|
else
|
|
|
|
prev = global_sigs[sig].sa_handler;
|
|
|
|
/* If func is SIG_HOLD, add sig to the signal mask, otherwise set the
|
|
|
|
disposition to func and remove sig from the signal mask. */
|
|
|
|
if (func == SIG_HOLD)
|
|
|
|
sigaddset (&mask, sig);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* No error checking. The test which could return SIG_ERR has already
|
2006-05-28 23:50:14 +08:00
|
|
|
been made above. */
|
2006-02-17 02:21:49 +08:00
|
|
|
signal (sig, func);
|
|
|
|
sigdelset (&mask, sig);
|
|
|
|
}
|
2008-02-16 01:53:11 +08:00
|
|
|
set_signal_mask (mask, _my_tls.sigmask);
|
2006-02-17 02:21:49 +08:00
|
|
|
mask_sync.release ();
|
|
|
|
return prev;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" int
|
|
|
|
sigignore (int sig)
|
|
|
|
{
|
|
|
|
return sigset (sig, SIG_IGN) == SIG_ERR ? -1 : 0;
|
|
|
|
}
|
|
|
|
|
2005-12-24 06:50:20 +08:00
|
|
|
/* Update the signal mask for this process and return the old mask.
|
2004-03-12 11:09:28 +08:00
|
|
|
Called from sigdelayed */
|
|
|
|
extern "C" sigset_t
|
|
|
|
set_process_mask_delta ()
|
|
|
|
{
|
2005-04-05 12:31:00 +08:00
|
|
|
mask_sync.acquire (INFINITE);
|
2004-03-12 11:09:28 +08:00
|
|
|
sigset_t newmask, oldmask;
|
|
|
|
|
|
|
|
if (_my_tls.deltamask & SIG_NONMASKABLE)
|
|
|
|
oldmask = _my_tls.oldmask; /* from handle_sigsuspend */
|
|
|
|
else
|
2008-02-16 01:53:11 +08:00
|
|
|
oldmask = _my_tls.sigmask;
|
2004-03-12 11:09:28 +08:00
|
|
|
newmask = (oldmask | _my_tls.deltamask) & ~SIG_NONMASKABLE;
|
|
|
|
sigproc_printf ("oldmask %p, newmask %p, deltamask %p", oldmask, newmask,
|
|
|
|
_my_tls.deltamask);
|
2008-02-16 01:53:11 +08:00
|
|
|
_my_tls.sigmask = newmask;
|
2005-04-05 12:31:00 +08:00
|
|
|
mask_sync.release ();
|
2004-03-12 11:09:28 +08:00
|
|
|
return oldmask;
|
|
|
|
}
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
/* Set the signal mask for this process.
|
2000-11-16 13:16:59 +08:00
|
|
|
Note that some signals are unmaskable, as in UNIX. */
|
2000-02-18 03:38:33 +08:00
|
|
|
extern "C" void __stdcall
|
2005-08-24 06:22:52 +08:00
|
|
|
set_signal_mask (sigset_t newmask, sigset_t& oldmask)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2005-08-29 11:12:39 +08:00
|
|
|
#ifdef CGF
|
2005-09-14 22:00:07 +08:00
|
|
|
if (&_my_tls == _sig_tls)
|
2005-08-29 07:26:23 +08:00
|
|
|
small_printf ("********* waiting in signal thread\n");
|
2005-08-29 11:12:39 +08:00
|
|
|
#endif
|
2005-04-05 12:31:00 +08:00
|
|
|
mask_sync.acquire (INFINITE);
|
2000-02-18 03:38:33 +08:00
|
|
|
newmask &= ~SIG_NONMASKABLE;
|
2003-12-24 00:26:31 +08:00
|
|
|
sigset_t mask_bits = oldmask & ~newmask;
|
|
|
|
sigproc_printf ("oldmask %p, newmask %p, mask_bits %p", oldmask, newmask,
|
|
|
|
mask_bits);
|
2005-08-24 06:22:52 +08:00
|
|
|
oldmask = newmask;
|
2003-12-24 00:26:31 +08:00
|
|
|
if (mask_bits)
|
2004-02-02 02:29:12 +08:00
|
|
|
sig_dispatch_pending (true);
|
2005-08-29 07:26:23 +08:00
|
|
|
mask_sync.release ();
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int __stdcall
|
2004-01-19 13:46:54 +08:00
|
|
|
sigpacket::process ()
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2004-01-27 06:25:57 +08:00
|
|
|
DWORD continue_now;
|
2006-07-18 03:30:30 +08:00
|
|
|
struct sigaction dummy = global_sigs[SIGSTOP];
|
|
|
|
|
2004-01-27 06:25:57 +08:00
|
|
|
if (si.si_signo != SIGCONT)
|
|
|
|
continue_now = false;
|
|
|
|
else
|
* devices.cc: New file.
* devices.gperf: New file.
* devices.shilka: New file.
* cygwin-gperf: New file.
* cygwin-shilka: New file.
* fhandler_fifo.cc: New file.
* fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes
fhandler.h throughout. Remove device argument and unit arguments from fhandler
constructors throughout. Remove pc arguments to fhandler functions and use
internal pc element instead, throughout. Use dev element in pc throughout.
Use major/minor elements rather than units and device numbers previously in
fhandler class. Use correct methods for fhandler file names rather than
directly accessing file name variables, throughout.
* Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o
* dcrt0.cc (dll_crt0_1): Call device::init.
* devices.h: Renumber devices based on more Linux-like major/minor numbers.
Add more devices. Declare standard device storage.
(device): Declare struct.
* dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type.
* dtable.cc (dtable::get_debugger_info): Ditto.
(cygwin_attach_handle_to_fd): Ditto.
(dtable::release): Remove special FH_SOCKET case in favor of generic
"need_fixup_before" test.
(dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name
to build standard fhandler.
(dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move
out of dtable class. Don't accept a path_conv argument. Just build it here
and pass it to:
(build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class.
Use intrinsic device type in path_conv to create new fhandler.
(build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class.
Simplify arguments to just take new 'device' type and a name. Just return
pointer to fhandler rather than trying to insert into dtable.
(dtable::dup_worker): Accommodate above build_fh name changes.
(dtable::find_fifo): New (currently broken) function.
(handle_to_fn): Use strechr for efficiency.
* dtable.h: Reflect above build_fh name changes and argument differences.
(fhandler_base *&operator []): Return self rather than copy of self.
* fhandler.cc (fhandler_base::operator =): Use pc element to set normalized
path.
(fhandler_base::set_name): Ditto.
(fhandler_base::raw_read): Use method to access name.
(fhandler_base::write): Correctly use get_output_handle rather than get_handle.
(handler_base::device_access_denied): New function.
(fhandler_base::open): Eliminate pc argument and use pc element of
fhandler_base throughout.
(fhandler_base::fstat): Detect if device is based in filesystem and use
fstat_fs to calculate stat, if so.
(fhandler_base::fhandler_base): Eliminate handling of file names and, instead,
just free appropriate component from pc.
(fhandler_base::opendir): Remove path_conv parameter.
* fhandler.h: Remove all device flags.
(fhandler_base::pc): New element.
(fhandler_base::set_name): Change argument to path_conv.
(fhandler_base::error): New function.
(fhandler_base::exists): New function.
(fhandler_base::pc_binmode): New function.
(fhandler_base::dev): New function.
(fhandler_base::open_fs): New function.
(fhandler_base::fstat_fs): New function.
(fhandler_base::fstat_by_name): New function.
(fhandler_base::fstat_by_handle): New function.
(fhandler_base::isfifo): New function.
(fhandler_base::is_slow): New function.
(fhandler_base::is_auto_device): New function.
(fhandler_base::is_fs_special): New function.
(fhandler_base::device_access_denied): New function.
(fhandler_base::operator DWORD&): New operator.
(fhandler_base::get_name): Return normalized path from pc.
(fhandler_base::get_win32_name): Return windows path from pc.
(fhandler_base::isdevice): Renamed from is_device.
(fhandler_base::get_native_name): Return device format.
(fhandler_fifo): New class.
(fhandler_nodevice): New class.
(select_stuff::device_specific): Remove array.
(select_stuff::device_specific_pipe): New class element.
(select_stuff::device_specific_socket): New class element.
(select_stuff::device_specific_serial): New class element.
(select_stuff::select_stuff): Initialize new elements.
* fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class
from fhandler_disk_file.
(fhandler_base::fstat_by_name): Ditto.
(fhandler_base::fstat_by_name): Ditto.
(fhandler_disk_file::open): Move most functionality into
fhandler_base::open_fs.
(fhandler_base::open_fs): New function.
(fhandler_disk_file::close): Move most functionality into
fhandler_base::close_fs.
(fhandler_base::close_fs): New function.
* fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging
output.
* fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard
urandom device into appropriate place.
(fhandler_socket::accept): Reflect change in fdsock return value.
* fhandler_tty.cc: See "throughouts" above.
* net.cc: Accommodate fdsock change throughout.
(fdsock): Return success or failure, accept fd argument and device argument.
* path.cc (symlink_info::major): New element.
(symlink_info::minor): New element.
(symlink_info::parse_device): Declare new function.
(fs_info::update): Accommodate changes in path_conv class.
(path_conv::fillin): Ditto.
(path_conv::return_and_clear_normalized_path): Eliminate.
(path_conv::set_normalized_path): New function.
(path_conv::path_conv): Set info in dev element. Use path_conv methods Check
for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff.
where appropriate rather than direct access. Use set_normalized_path to set
normalized path.
(windows_device_names): Eliminate.
(get_dev): Ditto.
(get_raw_device_number): Ditto.
(get_device_number): Ditto.
(win32_device_name): Call new device name parser to do most of the heavy
lifting.
(mount_info::conv_to_win32_path): Fill in dev field as appropriate.
(symlink_worker): Handle new device files.
(symlink_info::check): Ditto.
(symlink_info::parse_device): Define new function.
* path.h (executable_states): Move here from fhandler.h.
(fs_info): Rename variables to *_storage and create methods for accessing same.
(path_conv): Add dev element, remove devn and unit and adjust inline methods to
accommodate.
(set_normalized_path): Declare new function.
* pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos.
(_pinfo::commune_send): Ditto.
* pipe.cc (fhandler_pipe::close): check for existence of handle before closing
it.
(handler_pipe::create): Rename from make_pipe. Change arguments to accept
fhandler_pipe array. Accommodate fifos.
(pipe): Rework to deal with fhandler_pipe::create changes.
(_pipe): Ditto.
* select.cc: Use individual device_specific types throughout rather than
indexing with obsolete device number.
(set_bits): Use is_socket call rather than checking device number.
* shared_info.h (CURR_MOUNT_MAGIC): Update.
(conv_to_win32_path): Reflect addition of device argument.
* syscalls.cc (mknod_worker): New function.
(open): Use build_fh_name to build fhandler.
(chown_worker): Detect if this is an 'auto' device rather than an on-filesystem
device and handle appropriately.
(chmod_device): New function.
(chmod): Detect if this is an 'auto' device rather than an on-filesystem device
and handle appropriately. Use chmod_device to set mode of in-filesystem
devices.
(stat_worker): Eliminate path_conv argument. Call build_fh_name to construct
fhandler. Use fh->error() rather than pc->error to detect errors in fhandler
construction.
(access_worker): New function pulled from access. Accommodate in-filesystem
devices.
(access): Use access_worker.
(fpathconf): Detect if this is an 'auto' device rather than an on-filesystem
device and handle appropriately.
(mknod_worker): New function.
(mknod32): New function.
(chroot): Free normalized path -- assuming it was actually cmalloced.
* tty.cc (create_tty_master): Tweak for new device class.
(tty::common_init): Ditto.
* winsup.h (stat_worker): Remove.
(symlink_worker): Declare.
* exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't
worry about pending_signals since sig_dispatch_pending should always do the
right thing now.
(sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3.
* pinfo.h: Move __SIG enum to sigproc.h.
(PICOM_FIFO): New enum element.
(_pinfo): Remove 'thread2signal' stuff throughout class.
(_pinfo::commune_send): Make varargs.
(_pinfo::sigtodo): Eliminate.
(_pinfo::thread2signal): Ditto.
* signal.cc (kill_worker): Eliminate call to setthread2signal.
* sigproc.cc (local_sigtodo): Eliminate.
(getlocal_sigtodo): Ditto.
(sigelem): New class.
(pending_signals): New class.
(sigqueue): New variable, start of sigqueue linked list.
(sigcatch_nonmain): Eliminate.
(sigcatch_main): Eliminate.
(sigcatch_nosync): Eliminate.
(sigcomplete_nonmain): Eliminate.
(pending_signals): Eliminate.
(sig_clear): Call signal thread to clear pending signals, unless already in
signal thread.
(sigpending): Call signal thread to get pending signals.
(sig_dispatch_pending): Eliminate use of pending_signals and just check
sigqueue.
(sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close
signal pipe handle.
(sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send
signals.
(getevent): Eliminate.
(pending_signals::add): New function.
(pending_signals::del): New function.
(pending_signals::next): New function.
(wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to
communicate and maintain a linked list of signals.
* sigproc.h: Move __SIG defines here. Add __SIGPENDING.
(sig_dispatch_pending): Remove "C" specifier.
(sig_handle): Accept a mask argument.
* thread.cc: Remove signal handling considerations throughout.
2003-09-25 08:37:18 +08:00
|
|
|
{
|
2004-01-27 06:25:57 +08:00
|
|
|
continue_now = myself->process_state & PID_STOPPED;
|
* devices.cc: New file.
* devices.gperf: New file.
* devices.shilka: New file.
* cygwin-gperf: New file.
* cygwin-shilka: New file.
* fhandler_fifo.cc: New file.
* fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes
fhandler.h throughout. Remove device argument and unit arguments from fhandler
constructors throughout. Remove pc arguments to fhandler functions and use
internal pc element instead, throughout. Use dev element in pc throughout.
Use major/minor elements rather than units and device numbers previously in
fhandler class. Use correct methods for fhandler file names rather than
directly accessing file name variables, throughout.
* Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o
* dcrt0.cc (dll_crt0_1): Call device::init.
* devices.h: Renumber devices based on more Linux-like major/minor numbers.
Add more devices. Declare standard device storage.
(device): Declare struct.
* dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type.
* dtable.cc (dtable::get_debugger_info): Ditto.
(cygwin_attach_handle_to_fd): Ditto.
(dtable::release): Remove special FH_SOCKET case in favor of generic
"need_fixup_before" test.
(dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name
to build standard fhandler.
(dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move
out of dtable class. Don't accept a path_conv argument. Just build it here
and pass it to:
(build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class.
Use intrinsic device type in path_conv to create new fhandler.
(build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class.
Simplify arguments to just take new 'device' type and a name. Just return
pointer to fhandler rather than trying to insert into dtable.
(dtable::dup_worker): Accommodate above build_fh name changes.
(dtable::find_fifo): New (currently broken) function.
(handle_to_fn): Use strechr for efficiency.
* dtable.h: Reflect above build_fh name changes and argument differences.
(fhandler_base *&operator []): Return self rather than copy of self.
* fhandler.cc (fhandler_base::operator =): Use pc element to set normalized
path.
(fhandler_base::set_name): Ditto.
(fhandler_base::raw_read): Use method to access name.
(fhandler_base::write): Correctly use get_output_handle rather than get_handle.
(handler_base::device_access_denied): New function.
(fhandler_base::open): Eliminate pc argument and use pc element of
fhandler_base throughout.
(fhandler_base::fstat): Detect if device is based in filesystem and use
fstat_fs to calculate stat, if so.
(fhandler_base::fhandler_base): Eliminate handling of file names and, instead,
just free appropriate component from pc.
(fhandler_base::opendir): Remove path_conv parameter.
* fhandler.h: Remove all device flags.
(fhandler_base::pc): New element.
(fhandler_base::set_name): Change argument to path_conv.
(fhandler_base::error): New function.
(fhandler_base::exists): New function.
(fhandler_base::pc_binmode): New function.
(fhandler_base::dev): New function.
(fhandler_base::open_fs): New function.
(fhandler_base::fstat_fs): New function.
(fhandler_base::fstat_by_name): New function.
(fhandler_base::fstat_by_handle): New function.
(fhandler_base::isfifo): New function.
(fhandler_base::is_slow): New function.
(fhandler_base::is_auto_device): New function.
(fhandler_base::is_fs_special): New function.
(fhandler_base::device_access_denied): New function.
(fhandler_base::operator DWORD&): New operator.
(fhandler_base::get_name): Return normalized path from pc.
(fhandler_base::get_win32_name): Return windows path from pc.
(fhandler_base::isdevice): Renamed from is_device.
(fhandler_base::get_native_name): Return device format.
(fhandler_fifo): New class.
(fhandler_nodevice): New class.
(select_stuff::device_specific): Remove array.
(select_stuff::device_specific_pipe): New class element.
(select_stuff::device_specific_socket): New class element.
(select_stuff::device_specific_serial): New class element.
(select_stuff::select_stuff): Initialize new elements.
* fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class
from fhandler_disk_file.
(fhandler_base::fstat_by_name): Ditto.
(fhandler_base::fstat_by_name): Ditto.
(fhandler_disk_file::open): Move most functionality into
fhandler_base::open_fs.
(fhandler_base::open_fs): New function.
(fhandler_disk_file::close): Move most functionality into
fhandler_base::close_fs.
(fhandler_base::close_fs): New function.
* fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging
output.
* fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard
urandom device into appropriate place.
(fhandler_socket::accept): Reflect change in fdsock return value.
* fhandler_tty.cc: See "throughouts" above.
* net.cc: Accommodate fdsock change throughout.
(fdsock): Return success or failure, accept fd argument and device argument.
* path.cc (symlink_info::major): New element.
(symlink_info::minor): New element.
(symlink_info::parse_device): Declare new function.
(fs_info::update): Accommodate changes in path_conv class.
(path_conv::fillin): Ditto.
(path_conv::return_and_clear_normalized_path): Eliminate.
(path_conv::set_normalized_path): New function.
(path_conv::path_conv): Set info in dev element. Use path_conv methods Check
for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff.
where appropriate rather than direct access. Use set_normalized_path to set
normalized path.
(windows_device_names): Eliminate.
(get_dev): Ditto.
(get_raw_device_number): Ditto.
(get_device_number): Ditto.
(win32_device_name): Call new device name parser to do most of the heavy
lifting.
(mount_info::conv_to_win32_path): Fill in dev field as appropriate.
(symlink_worker): Handle new device files.
(symlink_info::check): Ditto.
(symlink_info::parse_device): Define new function.
* path.h (executable_states): Move here from fhandler.h.
(fs_info): Rename variables to *_storage and create methods for accessing same.
(path_conv): Add dev element, remove devn and unit and adjust inline methods to
accommodate.
(set_normalized_path): Declare new function.
* pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos.
(_pinfo::commune_send): Ditto.
* pipe.cc (fhandler_pipe::close): check for existence of handle before closing
it.
(handler_pipe::create): Rename from make_pipe. Change arguments to accept
fhandler_pipe array. Accommodate fifos.
(pipe): Rework to deal with fhandler_pipe::create changes.
(_pipe): Ditto.
* select.cc: Use individual device_specific types throughout rather than
indexing with obsolete device number.
(set_bits): Use is_socket call rather than checking device number.
* shared_info.h (CURR_MOUNT_MAGIC): Update.
(conv_to_win32_path): Reflect addition of device argument.
* syscalls.cc (mknod_worker): New function.
(open): Use build_fh_name to build fhandler.
(chown_worker): Detect if this is an 'auto' device rather than an on-filesystem
device and handle appropriately.
(chmod_device): New function.
(chmod): Detect if this is an 'auto' device rather than an on-filesystem device
and handle appropriately. Use chmod_device to set mode of in-filesystem
devices.
(stat_worker): Eliminate path_conv argument. Call build_fh_name to construct
fhandler. Use fh->error() rather than pc->error to detect errors in fhandler
construction.
(access_worker): New function pulled from access. Accommodate in-filesystem
devices.
(access): Use access_worker.
(fpathconf): Detect if this is an 'auto' device rather than an on-filesystem
device and handle appropriately.
(mknod_worker): New function.
(mknod32): New function.
(chroot): Free normalized path -- assuming it was actually cmalloced.
* tty.cc (create_tty_master): Tweak for new device class.
(tty::common_init): Ditto.
* winsup.h (stat_worker): Remove.
(symlink_worker): Declare.
* exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't
worry about pending_signals since sig_dispatch_pending should always do the
right thing now.
(sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3.
* pinfo.h: Move __SIG enum to sigproc.h.
(PICOM_FIFO): New enum element.
(_pinfo): Remove 'thread2signal' stuff throughout class.
(_pinfo::commune_send): Make varargs.
(_pinfo::sigtodo): Eliminate.
(_pinfo::thread2signal): Ditto.
* signal.cc (kill_worker): Eliminate call to setthread2signal.
* sigproc.cc (local_sigtodo): Eliminate.
(getlocal_sigtodo): Ditto.
(sigelem): New class.
(pending_signals): New class.
(sigqueue): New variable, start of sigqueue linked list.
(sigcatch_nonmain): Eliminate.
(sigcatch_main): Eliminate.
(sigcatch_nosync): Eliminate.
(sigcomplete_nonmain): Eliminate.
(pending_signals): Eliminate.
(sig_clear): Call signal thread to clear pending signals, unless already in
signal thread.
(sigpending): Call signal thread to get pending signals.
(sig_dispatch_pending): Eliminate use of pending_signals and just check
sigqueue.
(sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close
signal pipe handle.
(sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send
signals.
(getevent): Eliminate.
(pending_signals::add): New function.
(pending_signals::del): New function.
(pending_signals::next): New function.
(wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to
communicate and maintain a linked list of signals.
* sigproc.h: Move __SIG defines here. Add __SIGPENDING.
(sig_dispatch_pending): Remove "C" specifier.
(sig_handle): Accept a mask argument.
* thread.cc: Remove signal handling considerations throughout.
2003-09-25 08:37:18 +08:00
|
|
|
myself->stopsig = 0;
|
|
|
|
myself->process_state &= ~PID_STOPPED;
|
|
|
|
/* Clear pending stop signals */
|
|
|
|
sig_clear (SIGSTOP);
|
|
|
|
sig_clear (SIGTSTP);
|
|
|
|
sig_clear (SIGTTIN);
|
|
|
|
sig_clear (SIGTTOU);
|
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2011-04-18 03:56:25 +08:00
|
|
|
switch (si.si_signo)
|
|
|
|
{
|
|
|
|
case SIGINT:
|
|
|
|
case SIGQUIT:
|
|
|
|
case SIGSTOP:
|
|
|
|
case SIGTSTP:
|
|
|
|
if (cygheap->ctty)
|
|
|
|
cygheap->ctty->sigflush ();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2003-11-29 04:55:59 +08:00
|
|
|
int rc = 1;
|
2004-01-19 13:46:54 +08:00
|
|
|
|
|
|
|
sigproc_printf ("signal %d processing", si.si_signo);
|
2006-01-02 01:15:01 +08:00
|
|
|
struct sigaction& thissig = global_sigs[si.si_signo];
|
2004-01-19 13:46:54 +08:00
|
|
|
|
|
|
|
myself->rusage_self.ru_nsignals++;
|
|
|
|
|
2005-08-25 11:12:48 +08:00
|
|
|
bool masked;
|
2005-10-01 07:52:13 +08:00
|
|
|
void *handler;
|
2011-11-14 09:29:49 +08:00
|
|
|
if (!have_execed || (void *) thissig.sa_handler == (void *) SIG_IGN)
|
2005-10-01 07:52:13 +08:00
|
|
|
handler = (void *) thissig.sa_handler;
|
|
|
|
else if (tls)
|
|
|
|
return 1;
|
2005-12-06 04:20:18 +08:00
|
|
|
else
|
2005-10-01 07:52:13 +08:00
|
|
|
handler = NULL;
|
2005-08-25 11:12:48 +08:00
|
|
|
|
2008-11-29 00:41:54 +08:00
|
|
|
_cygtls *use_tls = tls ?: _main_tls;
|
2008-11-28 10:56:09 +08:00
|
|
|
|
2004-01-19 13:46:54 +08:00
|
|
|
if (si.si_signo == SIGKILL)
|
|
|
|
goto exit_sig;
|
2005-08-25 11:12:48 +08:00
|
|
|
if (si.si_signo == SIGSTOP)
|
* devices.cc: New file.
* devices.gperf: New file.
* devices.shilka: New file.
* cygwin-gperf: New file.
* cygwin-shilka: New file.
* fhandler_fifo.cc: New file.
* fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes
fhandler.h throughout. Remove device argument and unit arguments from fhandler
constructors throughout. Remove pc arguments to fhandler functions and use
internal pc element instead, throughout. Use dev element in pc throughout.
Use major/minor elements rather than units and device numbers previously in
fhandler class. Use correct methods for fhandler file names rather than
directly accessing file name variables, throughout.
* Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o
* dcrt0.cc (dll_crt0_1): Call device::init.
* devices.h: Renumber devices based on more Linux-like major/minor numbers.
Add more devices. Declare standard device storage.
(device): Declare struct.
* dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type.
* dtable.cc (dtable::get_debugger_info): Ditto.
(cygwin_attach_handle_to_fd): Ditto.
(dtable::release): Remove special FH_SOCKET case in favor of generic
"need_fixup_before" test.
(dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name
to build standard fhandler.
(dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move
out of dtable class. Don't accept a path_conv argument. Just build it here
and pass it to:
(build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class.
Use intrinsic device type in path_conv to create new fhandler.
(build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class.
Simplify arguments to just take new 'device' type and a name. Just return
pointer to fhandler rather than trying to insert into dtable.
(dtable::dup_worker): Accommodate above build_fh name changes.
(dtable::find_fifo): New (currently broken) function.
(handle_to_fn): Use strechr for efficiency.
* dtable.h: Reflect above build_fh name changes and argument differences.
(fhandler_base *&operator []): Return self rather than copy of self.
* fhandler.cc (fhandler_base::operator =): Use pc element to set normalized
path.
(fhandler_base::set_name): Ditto.
(fhandler_base::raw_read): Use method to access name.
(fhandler_base::write): Correctly use get_output_handle rather than get_handle.
(handler_base::device_access_denied): New function.
(fhandler_base::open): Eliminate pc argument and use pc element of
fhandler_base throughout.
(fhandler_base::fstat): Detect if device is based in filesystem and use
fstat_fs to calculate stat, if so.
(fhandler_base::fhandler_base): Eliminate handling of file names and, instead,
just free appropriate component from pc.
(fhandler_base::opendir): Remove path_conv parameter.
* fhandler.h: Remove all device flags.
(fhandler_base::pc): New element.
(fhandler_base::set_name): Change argument to path_conv.
(fhandler_base::error): New function.
(fhandler_base::exists): New function.
(fhandler_base::pc_binmode): New function.
(fhandler_base::dev): New function.
(fhandler_base::open_fs): New function.
(fhandler_base::fstat_fs): New function.
(fhandler_base::fstat_by_name): New function.
(fhandler_base::fstat_by_handle): New function.
(fhandler_base::isfifo): New function.
(fhandler_base::is_slow): New function.
(fhandler_base::is_auto_device): New function.
(fhandler_base::is_fs_special): New function.
(fhandler_base::device_access_denied): New function.
(fhandler_base::operator DWORD&): New operator.
(fhandler_base::get_name): Return normalized path from pc.
(fhandler_base::get_win32_name): Return windows path from pc.
(fhandler_base::isdevice): Renamed from is_device.
(fhandler_base::get_native_name): Return device format.
(fhandler_fifo): New class.
(fhandler_nodevice): New class.
(select_stuff::device_specific): Remove array.
(select_stuff::device_specific_pipe): New class element.
(select_stuff::device_specific_socket): New class element.
(select_stuff::device_specific_serial): New class element.
(select_stuff::select_stuff): Initialize new elements.
* fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class
from fhandler_disk_file.
(fhandler_base::fstat_by_name): Ditto.
(fhandler_base::fstat_by_name): Ditto.
(fhandler_disk_file::open): Move most functionality into
fhandler_base::open_fs.
(fhandler_base::open_fs): New function.
(fhandler_disk_file::close): Move most functionality into
fhandler_base::close_fs.
(fhandler_base::close_fs): New function.
* fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging
output.
* fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard
urandom device into appropriate place.
(fhandler_socket::accept): Reflect change in fdsock return value.
* fhandler_tty.cc: See "throughouts" above.
* net.cc: Accommodate fdsock change throughout.
(fdsock): Return success or failure, accept fd argument and device argument.
* path.cc (symlink_info::major): New element.
(symlink_info::minor): New element.
(symlink_info::parse_device): Declare new function.
(fs_info::update): Accommodate changes in path_conv class.
(path_conv::fillin): Ditto.
(path_conv::return_and_clear_normalized_path): Eliminate.
(path_conv::set_normalized_path): New function.
(path_conv::path_conv): Set info in dev element. Use path_conv methods Check
for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff.
where appropriate rather than direct access. Use set_normalized_path to set
normalized path.
(windows_device_names): Eliminate.
(get_dev): Ditto.
(get_raw_device_number): Ditto.
(get_device_number): Ditto.
(win32_device_name): Call new device name parser to do most of the heavy
lifting.
(mount_info::conv_to_win32_path): Fill in dev field as appropriate.
(symlink_worker): Handle new device files.
(symlink_info::check): Ditto.
(symlink_info::parse_device): Define new function.
* path.h (executable_states): Move here from fhandler.h.
(fs_info): Rename variables to *_storage and create methods for accessing same.
(path_conv): Add dev element, remove devn and unit and adjust inline methods to
accommodate.
(set_normalized_path): Declare new function.
* pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos.
(_pinfo::commune_send): Ditto.
* pipe.cc (fhandler_pipe::close): check for existence of handle before closing
it.
(handler_pipe::create): Rename from make_pipe. Change arguments to accept
fhandler_pipe array. Accommodate fifos.
(pipe): Rework to deal with fhandler_pipe::create changes.
(_pipe): Ditto.
* select.cc: Use individual device_specific types throughout rather than
indexing with obsolete device number.
(set_bits): Use is_socket call rather than checking device number.
* shared_info.h (CURR_MOUNT_MAGIC): Update.
(conv_to_win32_path): Reflect addition of device argument.
* syscalls.cc (mknod_worker): New function.
(open): Use build_fh_name to build fhandler.
(chown_worker): Detect if this is an 'auto' device rather than an on-filesystem
device and handle appropriately.
(chmod_device): New function.
(chmod): Detect if this is an 'auto' device rather than an on-filesystem device
and handle appropriately. Use chmod_device to set mode of in-filesystem
devices.
(stat_worker): Eliminate path_conv argument. Call build_fh_name to construct
fhandler. Use fh->error() rather than pc->error to detect errors in fhandler
construction.
(access_worker): New function pulled from access. Accommodate in-filesystem
devices.
(access): Use access_worker.
(fpathconf): Detect if this is an 'auto' device rather than an on-filesystem
device and handle appropriately.
(mknod_worker): New function.
(mknod32): New function.
(chroot): Free normalized path -- assuming it was actually cmalloced.
* tty.cc (create_tty_master): Tweak for new device class.
(tty::common_init): Ditto.
* winsup.h (stat_worker): Remove.
(symlink_worker): Declare.
* exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't
worry about pending_signals since sig_dispatch_pending should always do the
right thing now.
(sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3.
* pinfo.h: Move __SIG enum to sigproc.h.
(PICOM_FIFO): New enum element.
(_pinfo): Remove 'thread2signal' stuff throughout class.
(_pinfo::commune_send): Make varargs.
(_pinfo::sigtodo): Eliminate.
(_pinfo::thread2signal): Ditto.
* signal.cc (kill_worker): Eliminate call to setthread2signal.
* sigproc.cc (local_sigtodo): Eliminate.
(getlocal_sigtodo): Ditto.
(sigelem): New class.
(pending_signals): New class.
(sigqueue): New variable, start of sigqueue linked list.
(sigcatch_nonmain): Eliminate.
(sigcatch_main): Eliminate.
(sigcatch_nosync): Eliminate.
(sigcomplete_nonmain): Eliminate.
(pending_signals): Eliminate.
(sig_clear): Call signal thread to clear pending signals, unless already in
signal thread.
(sigpending): Call signal thread to get pending signals.
(sig_dispatch_pending): Eliminate use of pending_signals and just check
sigqueue.
(sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close
signal pipe handle.
(sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send
signals.
(getevent): Eliminate.
(pending_signals::add): New function.
(pending_signals::del): New function.
(pending_signals::next): New function.
(wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to
communicate and maintain a linked list of signals.
* sigproc.h: Move __SIG defines here. Add __SIGPENDING.
(sig_dispatch_pending): Remove "C" specifier.
(sig_handle): Accept a mask argument.
* thread.cc: Remove signal handling considerations throughout.
2003-09-25 08:37:18 +08:00
|
|
|
{
|
2004-01-19 13:46:54 +08:00
|
|
|
sig_clear (SIGCONT);
|
|
|
|
goto stop;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool insigwait_mask;
|
2005-08-25 11:12:48 +08:00
|
|
|
if ((masked = ISSTATE (myself, PID_STOPPED)))
|
|
|
|
insigwait_mask = false;
|
2008-11-29 00:41:54 +08:00
|
|
|
else if (tls)
|
2005-08-25 11:12:48 +08:00
|
|
|
insigwait_mask = sigismember (&tls->sigwait_mask, si.si_signo);
|
2009-09-19 05:27:02 +08:00
|
|
|
else if (!(tls = _cygtls::find_tls (si.si_signo)))
|
|
|
|
insigwait_mask = false;
|
2008-11-29 00:41:54 +08:00
|
|
|
else
|
|
|
|
{
|
2009-09-19 05:27:02 +08:00
|
|
|
use_tls = tls;
|
|
|
|
insigwait_mask = true;
|
2008-11-29 00:41:54 +08:00
|
|
|
}
|
2004-01-19 13:46:54 +08:00
|
|
|
|
|
|
|
if (insigwait_mask)
|
|
|
|
goto thread_specific;
|
|
|
|
|
2005-08-25 11:12:48 +08:00
|
|
|
if (masked)
|
|
|
|
/* nothing to do */;
|
|
|
|
else if (sigismember (mask, si.si_signo))
|
|
|
|
masked = true;
|
2008-11-29 00:41:54 +08:00
|
|
|
else if (tls)
|
2005-08-25 11:12:48 +08:00
|
|
|
masked = sigismember (&tls->sigmask, si.si_signo);
|
|
|
|
|
|
|
|
if (masked)
|
2004-01-19 13:46:54 +08:00
|
|
|
{
|
|
|
|
sigproc_printf ("signal %d blocked", si.si_signo);
|
2003-11-29 04:55:59 +08:00
|
|
|
rc = -1;
|
|
|
|
goto done;
|
* devices.cc: New file.
* devices.gperf: New file.
* devices.shilka: New file.
* cygwin-gperf: New file.
* cygwin-shilka: New file.
* fhandler_fifo.cc: New file.
* fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes
fhandler.h throughout. Remove device argument and unit arguments from fhandler
constructors throughout. Remove pc arguments to fhandler functions and use
internal pc element instead, throughout. Use dev element in pc throughout.
Use major/minor elements rather than units and device numbers previously in
fhandler class. Use correct methods for fhandler file names rather than
directly accessing file name variables, throughout.
* Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o
* dcrt0.cc (dll_crt0_1): Call device::init.
* devices.h: Renumber devices based on more Linux-like major/minor numbers.
Add more devices. Declare standard device storage.
(device): Declare struct.
* dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type.
* dtable.cc (dtable::get_debugger_info): Ditto.
(cygwin_attach_handle_to_fd): Ditto.
(dtable::release): Remove special FH_SOCKET case in favor of generic
"need_fixup_before" test.
(dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name
to build standard fhandler.
(dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move
out of dtable class. Don't accept a path_conv argument. Just build it here
and pass it to:
(build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class.
Use intrinsic device type in path_conv to create new fhandler.
(build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class.
Simplify arguments to just take new 'device' type and a name. Just return
pointer to fhandler rather than trying to insert into dtable.
(dtable::dup_worker): Accommodate above build_fh name changes.
(dtable::find_fifo): New (currently broken) function.
(handle_to_fn): Use strechr for efficiency.
* dtable.h: Reflect above build_fh name changes and argument differences.
(fhandler_base *&operator []): Return self rather than copy of self.
* fhandler.cc (fhandler_base::operator =): Use pc element to set normalized
path.
(fhandler_base::set_name): Ditto.
(fhandler_base::raw_read): Use method to access name.
(fhandler_base::write): Correctly use get_output_handle rather than get_handle.
(handler_base::device_access_denied): New function.
(fhandler_base::open): Eliminate pc argument and use pc element of
fhandler_base throughout.
(fhandler_base::fstat): Detect if device is based in filesystem and use
fstat_fs to calculate stat, if so.
(fhandler_base::fhandler_base): Eliminate handling of file names and, instead,
just free appropriate component from pc.
(fhandler_base::opendir): Remove path_conv parameter.
* fhandler.h: Remove all device flags.
(fhandler_base::pc): New element.
(fhandler_base::set_name): Change argument to path_conv.
(fhandler_base::error): New function.
(fhandler_base::exists): New function.
(fhandler_base::pc_binmode): New function.
(fhandler_base::dev): New function.
(fhandler_base::open_fs): New function.
(fhandler_base::fstat_fs): New function.
(fhandler_base::fstat_by_name): New function.
(fhandler_base::fstat_by_handle): New function.
(fhandler_base::isfifo): New function.
(fhandler_base::is_slow): New function.
(fhandler_base::is_auto_device): New function.
(fhandler_base::is_fs_special): New function.
(fhandler_base::device_access_denied): New function.
(fhandler_base::operator DWORD&): New operator.
(fhandler_base::get_name): Return normalized path from pc.
(fhandler_base::get_win32_name): Return windows path from pc.
(fhandler_base::isdevice): Renamed from is_device.
(fhandler_base::get_native_name): Return device format.
(fhandler_fifo): New class.
(fhandler_nodevice): New class.
(select_stuff::device_specific): Remove array.
(select_stuff::device_specific_pipe): New class element.
(select_stuff::device_specific_socket): New class element.
(select_stuff::device_specific_serial): New class element.
(select_stuff::select_stuff): Initialize new elements.
* fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class
from fhandler_disk_file.
(fhandler_base::fstat_by_name): Ditto.
(fhandler_base::fstat_by_name): Ditto.
(fhandler_disk_file::open): Move most functionality into
fhandler_base::open_fs.
(fhandler_base::open_fs): New function.
(fhandler_disk_file::close): Move most functionality into
fhandler_base::close_fs.
(fhandler_base::close_fs): New function.
* fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging
output.
* fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard
urandom device into appropriate place.
(fhandler_socket::accept): Reflect change in fdsock return value.
* fhandler_tty.cc: See "throughouts" above.
* net.cc: Accommodate fdsock change throughout.
(fdsock): Return success or failure, accept fd argument and device argument.
* path.cc (symlink_info::major): New element.
(symlink_info::minor): New element.
(symlink_info::parse_device): Declare new function.
(fs_info::update): Accommodate changes in path_conv class.
(path_conv::fillin): Ditto.
(path_conv::return_and_clear_normalized_path): Eliminate.
(path_conv::set_normalized_path): New function.
(path_conv::path_conv): Set info in dev element. Use path_conv methods Check
for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff.
where appropriate rather than direct access. Use set_normalized_path to set
normalized path.
(windows_device_names): Eliminate.
(get_dev): Ditto.
(get_raw_device_number): Ditto.
(get_device_number): Ditto.
(win32_device_name): Call new device name parser to do most of the heavy
lifting.
(mount_info::conv_to_win32_path): Fill in dev field as appropriate.
(symlink_worker): Handle new device files.
(symlink_info::check): Ditto.
(symlink_info::parse_device): Define new function.
* path.h (executable_states): Move here from fhandler.h.
(fs_info): Rename variables to *_storage and create methods for accessing same.
(path_conv): Add dev element, remove devn and unit and adjust inline methods to
accommodate.
(set_normalized_path): Declare new function.
* pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos.
(_pinfo::commune_send): Ditto.
* pipe.cc (fhandler_pipe::close): check for existence of handle before closing
it.
(handler_pipe::create): Rename from make_pipe. Change arguments to accept
fhandler_pipe array. Accommodate fifos.
(pipe): Rework to deal with fhandler_pipe::create changes.
(_pipe): Ditto.
* select.cc: Use individual device_specific types throughout rather than
indexing with obsolete device number.
(set_bits): Use is_socket call rather than checking device number.
* shared_info.h (CURR_MOUNT_MAGIC): Update.
(conv_to_win32_path): Reflect addition of device argument.
* syscalls.cc (mknod_worker): New function.
(open): Use build_fh_name to build fhandler.
(chown_worker): Detect if this is an 'auto' device rather than an on-filesystem
device and handle appropriately.
(chmod_device): New function.
(chmod): Detect if this is an 'auto' device rather than an on-filesystem device
and handle appropriately. Use chmod_device to set mode of in-filesystem
devices.
(stat_worker): Eliminate path_conv argument. Call build_fh_name to construct
fhandler. Use fh->error() rather than pc->error to detect errors in fhandler
construction.
(access_worker): New function pulled from access. Accommodate in-filesystem
devices.
(access): Use access_worker.
(fpathconf): Detect if this is an 'auto' device rather than an on-filesystem
device and handle appropriately.
(mknod_worker): New function.
(mknod32): New function.
(chroot): Free normalized path -- assuming it was actually cmalloced.
* tty.cc (create_tty_master): Tweak for new device class.
(tty::common_init): Ditto.
* winsup.h (stat_worker): Remove.
(symlink_worker): Declare.
* exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't
worry about pending_signals since sig_dispatch_pending should always do the
right thing now.
(sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3.
* pinfo.h: Move __SIG enum to sigproc.h.
(PICOM_FIFO): New enum element.
(_pinfo): Remove 'thread2signal' stuff throughout class.
(_pinfo::commune_send): Make varargs.
(_pinfo::sigtodo): Eliminate.
(_pinfo::thread2signal): Ditto.
* signal.cc (kill_worker): Eliminate call to setthread2signal.
* sigproc.cc (local_sigtodo): Eliminate.
(getlocal_sigtodo): Ditto.
(sigelem): New class.
(pending_signals): New class.
(sigqueue): New variable, start of sigqueue linked list.
(sigcatch_nonmain): Eliminate.
(sigcatch_main): Eliminate.
(sigcatch_nosync): Eliminate.
(sigcomplete_nonmain): Eliminate.
(pending_signals): Eliminate.
(sig_clear): Call signal thread to clear pending signals, unless already in
signal thread.
(sigpending): Call signal thread to get pending signals.
(sig_dispatch_pending): Eliminate use of pending_signals and just check
sigqueue.
(sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close
signal pipe handle.
(sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send
signals.
(getevent): Eliminate.
(pending_signals::add): New function.
(pending_signals::del): New function.
(pending_signals::next): New function.
(wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to
communicate and maintain a linked list of signals.
* sigproc.h: Move __SIG defines here. Add __SIGPENDING.
(sig_dispatch_pending): Remove "C" specifier.
(sig_handle): Accept a mask argument.
* thread.cc: Remove signal handling considerations throughout.
2003-09-25 08:37:18 +08:00
|
|
|
}
|
|
|
|
|
2004-01-19 13:46:54 +08:00
|
|
|
/* Clear pending SIGCONT on stop signals */
|
|
|
|
if (si.si_signo == SIGTSTP || si.si_signo == SIGTTIN || si.si_signo == SIGTTOU)
|
|
|
|
sig_clear (SIGCONT);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
if (handler == (void *) SIG_DFL)
|
|
|
|
{
|
2003-11-29 04:55:59 +08:00
|
|
|
if (insigwait_mask)
|
|
|
|
goto thread_specific;
|
2004-01-19 13:46:54 +08:00
|
|
|
if (si.si_signo == SIGCHLD || si.si_signo == SIGIO || si.si_signo == SIGCONT || si.si_signo == SIGWINCH
|
|
|
|
|| si.si_signo == SIGURG)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2004-01-19 13:46:54 +08:00
|
|
|
sigproc_printf ("default signal %d ignored", si.si_signo);
|
2004-01-27 06:25:57 +08:00
|
|
|
if (continue_now)
|
|
|
|
SetEvent (signal_arrived);
|
2000-02-18 03:38:33 +08:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2004-01-19 13:46:54 +08:00
|
|
|
if (si.si_signo == SIGTSTP || si.si_signo == SIGTTIN || si.si_signo == SIGTTOU)
|
2000-02-18 03:38:33 +08:00
|
|
|
goto stop;
|
|
|
|
|
|
|
|
goto exit_sig;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (handler == (void *) SIG_IGN)
|
|
|
|
{
|
2004-01-19 13:46:54 +08:00
|
|
|
sigproc_printf ("signal %d ignored", si.si_signo);
|
2000-02-18 03:38:33 +08:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (handler == (void *) SIG_ERR)
|
|
|
|
goto exit_sig;
|
|
|
|
|
2008-11-29 00:41:54 +08:00
|
|
|
use_tls->set_siginfo (this);
|
2000-02-18 03:38:33 +08:00
|
|
|
goto dosig;
|
|
|
|
|
2003-09-09 11:11:31 +08:00
|
|
|
stop:
|
2001-01-17 22:57:09 +08:00
|
|
|
/* Eat multiple attempts to STOP */
|
|
|
|
if (ISSTATE (myself, PID_STOPPED))
|
|
|
|
goto done;
|
2000-02-18 03:38:33 +08:00
|
|
|
handler = (void *) sig_handle_tty_stop;
|
2006-01-02 01:15:01 +08:00
|
|
|
thissig = dummy;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2003-09-09 11:11:31 +08:00
|
|
|
dosig:
|
2000-02-18 03:38:33 +08:00
|
|
|
/* Dispatch to the appropriate function. */
|
2004-01-19 13:46:54 +08:00
|
|
|
sigproc_printf ("signal %d, about to call %p", si.si_signo, handler);
|
2008-11-29 00:41:54 +08:00
|
|
|
rc = setup_handler (si.si_signo, handler, thissig, use_tls);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2003-09-09 11:11:31 +08:00
|
|
|
done:
|
2008-11-29 10:41:38 +08:00
|
|
|
tls = use_tls;
|
2004-01-27 06:25:57 +08:00
|
|
|
if (continue_now)
|
|
|
|
SetEvent (sigCONT);
|
2000-02-18 03:38:33 +08:00
|
|
|
sigproc_printf ("returning %d", rc);
|
|
|
|
return rc;
|
|
|
|
|
2003-11-29 04:55:59 +08:00
|
|
|
thread_specific:
|
2008-11-29 00:41:54 +08:00
|
|
|
use_tls->sig = si.si_signo;
|
|
|
|
use_tls->set_siginfo (this);
|
2009-09-19 23:34:19 +08:00
|
|
|
use_tls->func = NULL;
|
2003-11-29 04:55:59 +08:00
|
|
|
sigproc_printf ("releasing sigwait for thread");
|
2008-11-29 00:41:54 +08:00
|
|
|
SetEvent (use_tls->event);
|
2003-11-29 04:55:59 +08:00
|
|
|
goto done;
|
|
|
|
|
2003-09-09 11:11:31 +08:00
|
|
|
exit_sig:
|
2008-11-29 00:41:54 +08:00
|
|
|
use_tls->signal_exit (si.si_signo); /* never returns */
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-07-05 11:16:46 +08:00
|
|
|
events_init ()
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2005-04-05 12:31:00 +08:00
|
|
|
mask_sync.init ("mask_sync");
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-07-05 11:16:46 +08:00
|
|
|
events_terminate ()
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
exit_already = 1;
|
|
|
|
}
|
|
|
|
|
2004-02-12 11:01:58 +08:00
|
|
|
int
|
|
|
|
_cygtls::call_signal_handler ()
|
2001-04-02 08:18:29 +08:00
|
|
|
{
|
2011-12-05 01:58:24 +08:00
|
|
|
int this_sa_flags = SA_RESTART;
|
|
|
|
while (1)
|
2001-09-12 13:09:24 +08:00
|
|
|
{
|
2005-12-24 06:50:20 +08:00
|
|
|
lock ();
|
2011-12-05 01:58:24 +08:00
|
|
|
if (sig)
|
|
|
|
pop ();
|
|
|
|
else if (this != _main_tls)
|
|
|
|
{
|
|
|
|
_main_tls->lock ();
|
2011-12-14 04:06:31 +08:00
|
|
|
if (_main_tls->sig && _main_tls->incyg)
|
2011-12-05 01:58:24 +08:00
|
|
|
{
|
2011-12-16 13:27:15 +08:00
|
|
|
paranoid_printf ("Redirecting to main_tls signal %d", _main_tls->sig);
|
2011-12-05 01:58:24 +08:00
|
|
|
sig = _main_tls->sig;
|
|
|
|
sa_flags = _main_tls->sa_flags;
|
|
|
|
func = _main_tls->func;
|
|
|
|
infodata = _main_tls->infodata;
|
|
|
|
_main_tls->pop ();
|
|
|
|
_main_tls->sig = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
_main_tls->unlock ();
|
|
|
|
}
|
|
|
|
if (!sig)
|
|
|
|
break;
|
|
|
|
|
2011-12-17 08:03:31 +08:00
|
|
|
debug_only_printf ("dealing with signal %d", sig);
|
2004-02-12 11:01:58 +08:00
|
|
|
this_sa_flags = sa_flags;
|
|
|
|
int thissig = sig;
|
2010-08-02 03:10:52 +08:00
|
|
|
void (*thisfunc) (int) = func;
|
2004-01-14 23:45:37 +08:00
|
|
|
|
2004-03-12 11:09:28 +08:00
|
|
|
sigset_t this_oldmask = set_process_mask_delta ();
|
2004-02-12 11:01:58 +08:00
|
|
|
int this_errno = saved_errno;
|
|
|
|
sig = 0;
|
2005-12-24 06:50:20 +08:00
|
|
|
unlock (); // make sure synchronized
|
2005-09-26 22:58:16 +08:00
|
|
|
if (!(this_sa_flags & SA_SIGINFO))
|
|
|
|
{
|
2010-08-02 03:10:52 +08:00
|
|
|
void (*sigfunc) (int) = thisfunc;
|
2011-12-05 01:58:24 +08:00
|
|
|
incyg = false;
|
2005-09-26 22:58:16 +08:00
|
|
|
sigfunc (thissig);
|
|
|
|
}
|
2005-09-26 22:51:48 +08:00
|
|
|
else
|
2005-12-22 13:57:54 +08:00
|
|
|
{
|
2005-09-26 22:51:48 +08:00
|
|
|
siginfo_t thissi = infodata;
|
2010-08-02 03:10:52 +08:00
|
|
|
void (*sigact) (int, siginfo_t *, void *) = (void (*) (int, siginfo_t *, void *)) thisfunc;
|
2005-12-22 13:57:54 +08:00
|
|
|
/* no ucontext_t information provided yet */
|
2011-12-05 01:58:24 +08:00
|
|
|
incyg = false;
|
2005-12-22 13:57:54 +08:00
|
|
|
sigact (thissig, &thissi, NULL);
|
|
|
|
}
|
2011-12-05 01:58:24 +08:00
|
|
|
incyg = true;
|
2008-02-16 01:53:11 +08:00
|
|
|
set_signal_mask (this_oldmask, _my_tls.sigmask);
|
2003-11-29 04:55:59 +08:00
|
|
|
if (this_errno >= 0)
|
|
|
|
set_errno (this_errno);
|
2001-09-12 13:09:24 +08:00
|
|
|
}
|
|
|
|
|
2011-12-05 01:58:24 +08:00
|
|
|
unlock ();
|
2011-12-14 04:06:31 +08:00
|
|
|
return this_sa_flags & SA_RESTART || (this != _main_tls);
|
2001-04-02 08:18:29 +08:00
|
|
|
}
|
2001-04-01 13:38:08 +08:00
|
|
|
|
2006-02-07 02:24:11 +08:00
|
|
|
void
|
|
|
|
_cygtls::copy_context (CONTEXT *c)
|
|
|
|
{
|
|
|
|
memcpy (&thread_context, c, (&thread_context._internal - (unsigned char *) &thread_context));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_cygtls::signal_debugger (int sig)
|
|
|
|
{
|
2006-06-04 04:32:07 +08:00
|
|
|
if (isinitialized () && being_debugged ())
|
2006-02-07 02:24:11 +08:00
|
|
|
{
|
|
|
|
char sigmsg[2 * sizeof (_CYGWIN_SIGNAL_STRING " ffffffff ffffffff")];
|
|
|
|
__small_sprintf (sigmsg, _CYGWIN_SIGNAL_STRING " %d %p %p", sig, thread_id, &thread_context);
|
|
|
|
OutputDebugString (sigmsg);
|
|
|
|
}
|
|
|
|
}
|