* path.cc (mount_info::cygdrive_posix_path): Don't add trailing slash if
referring to something like c:\. * dcrt0.cc (dll_crt0_1): Move uinfo initialization prior to sig_send initialization to give signal thread a chance to finish. * debug.cc (WFSO): Move to sigproc.cc (WFMO): Ditto. * exceptions.cc (interruptible): Allocate slightly more space for directory just for paranoia's sake. (call_handler): Eliminate nonmain argument. Determine if main thread has set a frame pointer and use it if so. (sig_handle): Eliminate nonmain argument. * net.cc: Record frame information in appropriate routines throughout. * select.cc (select): Ditto. * sigproc.cc: Use sigthread structure to record mainthread id throughout. (sig_send): Record frame information for signal handler. (wait_sig): Reflect argument change in sig_handle. (WFSO): Move here and record frame information for signal handler. (WFMO): Ditto. * sigproc.h: Implement new "sigthread" class. Implement "sigframe" class for manipulating signal frame info. * thread.cc (__pthread_kill): Use standard _kill() function rather than calling sig_send directly. * winsup.h: Eliminate ebp element from signal_dispatch class.
This commit is contained in:
parent
8c1c1f1a43
commit
6201d15e3c
|
@ -1,3 +1,30 @@
|
||||||
|
Wed May 17 01:05:52 2000 Christopher Faylor <cgf@cygnus.com>
|
||||||
|
|
||||||
|
* path.cc (mount_info::cygdrive_posix_path): Don't add trailing slash
|
||||||
|
if referring to something like c:\.
|
||||||
|
* dcrt0.cc (dll_crt0_1): Move uinfo initialization prior to sig_send
|
||||||
|
initialization to give signal thread a chance to finish.
|
||||||
|
* debug.cc (WFSO): Move to sigproc.cc
|
||||||
|
(WFMO): Ditto.
|
||||||
|
* exceptions.cc (interruptible): Allocate slightly more space for
|
||||||
|
directory just for paranoia's sake.
|
||||||
|
(call_handler): Eliminate nonmain argument. Determine if main thread
|
||||||
|
has set a frame pointer and use it if so.
|
||||||
|
(sig_handle): Eliminate nonmain argument.
|
||||||
|
* net.cc: Record frame information in appropriate routines throughout.
|
||||||
|
* select.cc (select): Ditto.
|
||||||
|
* sigproc.cc: Use sigthread structure to record mainthread id
|
||||||
|
throughout.
|
||||||
|
(sig_send): Record frame information for signal handler.
|
||||||
|
(wait_sig): Reflect argument change in sig_handle.
|
||||||
|
(WFSO): Move here and record frame information for signal handler.
|
||||||
|
(WFMO): Ditto.
|
||||||
|
* sigproc.h: Implement new "sigthread" class. Implement "sigframe"
|
||||||
|
class for manipulating signal frame info.
|
||||||
|
* thread.cc (__pthread_kill): Use standard _kill() function rather than
|
||||||
|
calling sig_send directly.
|
||||||
|
* winsup.h: Eliminate ebp element from signal_dispatch class.
|
||||||
|
|
||||||
Tue May 16 23:39:00 2000 Corinna Vinschen <corinna@vinschen.de>
|
Tue May 16 23:39:00 2000 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
Patch suggested by John Rowley <wjr@bgs.ac.uk>
|
Patch suggested by John Rowley <wjr@bgs.ac.uk>
|
||||||
|
|
|
@ -746,15 +746,15 @@ dll_crt0_1 ()
|
||||||
set_errno (0);
|
set_errno (0);
|
||||||
debug_printf ("user_data->main %p", user_data->main);
|
debug_printf ("user_data->main %p", user_data->main);
|
||||||
|
|
||||||
|
/* Initialize uid, gid. */
|
||||||
|
uinfo_init ();
|
||||||
|
|
||||||
/* Flush signals and ensure that signal thread is up and running. Can't
|
/* Flush signals and ensure that signal thread is up and running. Can't
|
||||||
do this for noncygwin case since the signal thread is blocked due to
|
do this for noncygwin case since the signal thread is blocked due to
|
||||||
LoadLibrary serialization. */
|
LoadLibrary serialization. */
|
||||||
if (!dynamically_loaded)
|
if (!dynamically_loaded)
|
||||||
sig_send (NULL, __SIGFLUSH);
|
sig_send (NULL, __SIGFLUSH);
|
||||||
|
|
||||||
/* Initialize uid, gid. */
|
|
||||||
uinfo_init ();
|
|
||||||
|
|
||||||
if (user_data->main && !dynamically_loaded)
|
if (user_data->main && !dynamically_loaded)
|
||||||
exit (user_data->main (argc, argv, *user_data->envptr));
|
exit (user_data->main (argc, argv, *user_data->envptr));
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@ details. */
|
||||||
#define NO_DEBUG_DEFINES
|
#define NO_DEBUG_DEFINES
|
||||||
#include "winsup.h"
|
#include "winsup.h"
|
||||||
#include "exceptions.h"
|
#include "exceptions.h"
|
||||||
#include "sync.h"
|
|
||||||
|
|
||||||
static muto NO_COPY *threadname_lock = NULL;
|
static muto NO_COPY *threadname_lock = NULL;
|
||||||
#define lock_threadname() \
|
#define lock_threadname() \
|
||||||
|
@ -52,7 +51,7 @@ int __stdcall
|
||||||
iscygthread()
|
iscygthread()
|
||||||
{
|
{
|
||||||
DWORD tid = GetCurrentThreadId ();
|
DWORD tid = GetCurrentThreadId ();
|
||||||
if (tid != maintid)
|
if (tid != mainthread.id)
|
||||||
for (DWORD i = 0; i < NTHREADS && threads[i].name != NULL; i++)
|
for (DWORD i = 0; i < NTHREADS && threads[i].name != NULL; i++)
|
||||||
if (threads[i].id == tid)
|
if (threads[i].id == tid)
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -302,27 +301,3 @@ close_handle (const char *func, int ln, HANDLE h, const char *name, BOOL force)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif /*DEBUGGING*/
|
#endif /*DEBUGGING*/
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
/* Provide a stack frame when calling WaitFor* functions */
|
|
||||||
|
|
||||||
#undef WaitForSingleObject
|
|
||||||
|
|
||||||
DWORD __stdcall
|
|
||||||
WFSO (HANDLE hHandle, DWORD dwMilliseconds)
|
|
||||||
{
|
|
||||||
DWORD ret;
|
|
||||||
ret = WaitForSingleObject (hHandle, dwMilliseconds);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef WaitForMultipleObjects
|
|
||||||
|
|
||||||
DWORD __stdcall
|
|
||||||
WFMO (DWORD nCount, CONST HANDLE *lpHandles, BOOL fWaitAll, DWORD dwMilliseconds)
|
|
||||||
{
|
|
||||||
DWORD ret;
|
|
||||||
ret = WaitForMultipleObjects (nCount, lpHandles, fWaitAll, dwMilliseconds);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -18,7 +18,6 @@ details. */
|
||||||
#define DECLSPEC_IMPORT
|
#define DECLSPEC_IMPORT
|
||||||
#include <imagehlp.h>
|
#include <imagehlp.h>
|
||||||
#include "autoload.h"
|
#include "autoload.h"
|
||||||
#include "sync.h"
|
|
||||||
|
|
||||||
char debugger_command[2 * MAX_PATH + 20];
|
char debugger_command[2 * MAX_PATH + 20];
|
||||||
|
|
||||||
|
@ -566,7 +565,8 @@ interruptible (DWORD pc)
|
||||||
if (!VirtualQuery ((LPCVOID) pc, &m, sizeof m))
|
if (!VirtualQuery ((LPCVOID) pc, &m, sizeof m))
|
||||||
sigproc_printf ("couldn't get memory info, %E");
|
sigproc_printf ("couldn't get memory info, %E");
|
||||||
|
|
||||||
char *checkdir = (char *) alloca (windows_system_directory_length + 2);
|
char *checkdir = (char *) alloca (windows_system_directory_length + 4);
|
||||||
|
memset (checkdir, 0, sizeof (checkdir));
|
||||||
# define h ((HMODULE) m.AllocationBase)
|
# define h ((HMODULE) m.AllocationBase)
|
||||||
if (h == user_data->hmodule)
|
if (h == user_data->hmodule)
|
||||||
res = 1;
|
res = 1;
|
||||||
|
@ -597,7 +597,6 @@ interrupt_setup (int sig, struct sigaction& siga, void *handler,
|
||||||
sigsave.func = (void (*)(int)) handler;
|
sigsave.func = (void (*)(int)) handler;
|
||||||
sigsave.sig = sig;
|
sigsave.sig = sig;
|
||||||
sigsave.saved_errno = -1; // Flag: no errno to save
|
sigsave.saved_errno = -1; // Flag: no errno to save
|
||||||
sigsave.ebp = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -656,18 +655,33 @@ set_sig_errno (int e)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
call_handler (int sig, struct sigaction& siga, void *handler, int nonmain)
|
call_handler (int sig, struct sigaction& siga, void *handler)
|
||||||
{
|
{
|
||||||
CONTEXT cx;
|
CONTEXT cx;
|
||||||
DWORD ebp;
|
|
||||||
int interrupted = 1;
|
int interrupted = 1;
|
||||||
HANDLE hth = NULL;
|
HANDLE hth = NULL;
|
||||||
|
DWORD ebp;
|
||||||
int res;
|
int res;
|
||||||
|
int locked;
|
||||||
|
|
||||||
if (!nonmain)
|
if (!mainthread.lock)
|
||||||
ebp = sigsave.ebp;
|
locked = 0;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
mainthread.lock->acquire ();
|
||||||
|
locked = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mainthread.frame)
|
||||||
|
ebp = mainthread.frame;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (locked)
|
||||||
|
{
|
||||||
|
mainthread.lock->release ();
|
||||||
|
locked = 0;
|
||||||
|
}
|
||||||
|
|
||||||
hth = myself->getthread2signal ();
|
hth = myself->getthread2signal ();
|
||||||
/* Suspend the thread which will receive the signal. But first ensure that
|
/* Suspend the thread which will receive the signal. But first ensure that
|
||||||
this thread doesn't have the sync_proc_subproc and mask_sync mutos, since
|
this thread doesn't have the sync_proc_subproc and mask_sync mutos, since
|
||||||
|
@ -682,9 +696,15 @@ call_handler (int sig, struct sigaction& siga, void *handler, int nonmain)
|
||||||
muto *m;
|
muto *m;
|
||||||
/* FIXME: Make multi-thread aware */
|
/* FIXME: Make multi-thread aware */
|
||||||
for (m = muto_start.next; m != NULL; m = m->next)
|
for (m = muto_start.next; m != NULL; m = m->next)
|
||||||
if (m->unstable () || m->owner () == maintid)
|
if (m->unstable () || m->owner () == mainthread.id)
|
||||||
goto keep_looping;
|
goto keep_looping;
|
||||||
|
|
||||||
|
if (mainthread.frame)
|
||||||
|
{
|
||||||
|
ebp = mainthread.frame; /* try to avoid a race */
|
||||||
|
goto ebp_set;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
keep_looping:
|
keep_looping:
|
||||||
|
@ -707,7 +727,8 @@ call_handler (int sig, struct sigaction& siga, void *handler, int nonmain)
|
||||||
ebp = cx.Ebp;
|
ebp = cx.Ebp;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hExeced != NULL || (nonmain && interruptible (cx.Eip)))
|
ebp_set:
|
||||||
|
if (hExeced != NULL || (!mainthread.frame && interruptible (cx.Eip)))
|
||||||
interrupt_now (&cx, sig, siga, handler);
|
interrupt_now (&cx, sig, siga, handler);
|
||||||
else if (!interrupt_on_return (ebp, sig, siga, handler))
|
else if (!interrupt_on_return (ebp, sig, siga, handler))
|
||||||
{
|
{
|
||||||
|
@ -734,6 +755,9 @@ out:
|
||||||
sigproc_printf ("ResumeThread returned %d", res);
|
sigproc_printf ("ResumeThread returned %d", res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (locked)
|
||||||
|
mainthread.lock->release ();
|
||||||
|
|
||||||
sigproc_printf ("returning %d", interrupted);
|
sigproc_printf ("returning %d", interrupted);
|
||||||
return interrupted;
|
return interrupted;
|
||||||
}
|
}
|
||||||
|
@ -835,7 +859,7 @@ sig_handle_tty_stop (int sig)
|
||||||
}
|
}
|
||||||
|
|
||||||
int __stdcall
|
int __stdcall
|
||||||
sig_handle (int sig, int nonmain)
|
sig_handle (int sig)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
|
@ -914,7 +938,7 @@ stop:
|
||||||
dosig:
|
dosig:
|
||||||
/* Dispatch to the appropriate function. */
|
/* Dispatch to the appropriate function. */
|
||||||
sigproc_printf ("signal %d, about to call %p", sig, thissig.sa_handler);
|
sigproc_printf ("signal %d, about to call %p", sig, thissig.sa_handler);
|
||||||
rc = call_handler (sig, thissig, handler, nonmain);
|
rc = call_handler (sig, thissig, handler);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
sigproc_printf ("returning %d", rc);
|
sigproc_printf ("returning %d", rc);
|
||||||
|
|
|
@ -13,7 +13,6 @@ details. */
|
||||||
|
|
||||||
#include "winsup.h"
|
#include "winsup.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "sync.h"
|
|
||||||
|
|
||||||
/* we provide these stubs to call into a user's
|
/* we provide these stubs to call into a user's
|
||||||
provided malloc if there is one - otherwise
|
provided malloc if there is one - otherwise
|
||||||
|
|
|
@ -421,6 +421,7 @@ cygwin_sendto (int fd,
|
||||||
{
|
{
|
||||||
fhandler_socket *h = (fhandler_socket *) dtable[fd];
|
fhandler_socket *h = (fhandler_socket *) dtable[fd];
|
||||||
sockaddr_in sin;
|
sockaddr_in sin;
|
||||||
|
sigframe thisframe (mainthread, 0);
|
||||||
|
|
||||||
if (get_inet_addr (to, tolen, &sin, &tolen) == 0)
|
if (get_inet_addr (to, tolen, &sin, &tolen) == 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -446,6 +447,7 @@ cygwin_recvfrom (int fd,
|
||||||
int *fromlen)
|
int *fromlen)
|
||||||
{
|
{
|
||||||
fhandler_socket *h = (fhandler_socket *) dtable[fd];
|
fhandler_socket *h = (fhandler_socket *) dtable[fd];
|
||||||
|
sigframe thisframe (mainthread, 0);
|
||||||
|
|
||||||
debug_printf ("recvfrom %d", h->get_socket ());
|
debug_printf ("recvfrom %d", h->get_socket ());
|
||||||
|
|
||||||
|
@ -602,6 +604,7 @@ cygwin_connect (int fd,
|
||||||
int res;
|
int res;
|
||||||
fhandler_socket *sock = get (fd);
|
fhandler_socket *sock = get (fd);
|
||||||
sockaddr_in sin;
|
sockaddr_in sin;
|
||||||
|
sigframe thisframe (mainthread, 0);
|
||||||
|
|
||||||
if (get_inet_addr (name, namelen, &sin, &namelen) == 0)
|
if (get_inet_addr (name, namelen, &sin, &namelen) == 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -714,6 +717,7 @@ int
|
||||||
cygwin_accept (int fd, struct sockaddr *peer, int *len)
|
cygwin_accept (int fd, struct sockaddr *peer, int *len)
|
||||||
{
|
{
|
||||||
int res = -1;
|
int res = -1;
|
||||||
|
sigframe thisframe (mainthread, 0);
|
||||||
|
|
||||||
fhandler_socket *sock = get (fd);
|
fhandler_socket *sock = get (fd);
|
||||||
if (sock)
|
if (sock)
|
||||||
|
@ -899,7 +903,7 @@ int
|
||||||
cygwin_shutdown (int fd, int how)
|
cygwin_shutdown (int fd, int how)
|
||||||
{
|
{
|
||||||
int res = -1;
|
int res = -1;
|
||||||
|
sigframe thisframe (mainthread, 0);
|
||||||
|
|
||||||
fhandler_socket *sock = get (fd);
|
fhandler_socket *sock = get (fd);
|
||||||
if (sock)
|
if (sock)
|
||||||
|
@ -942,6 +946,7 @@ int
|
||||||
cygwin_recv (int fd, void *buf, int len, unsigned int flags)
|
cygwin_recv (int fd, void *buf, int len, unsigned int flags)
|
||||||
{
|
{
|
||||||
fhandler_socket *h = (fhandler_socket *) dtable[fd];
|
fhandler_socket *h = (fhandler_socket *) dtable[fd];
|
||||||
|
sigframe thisframe (mainthread, 0);
|
||||||
|
|
||||||
int res = recv (h->get_socket (), (char *) buf, len, flags);
|
int res = recv (h->get_socket (), (char *) buf, len, flags);
|
||||||
if (res == SOCKET_ERROR)
|
if (res == SOCKET_ERROR)
|
||||||
|
@ -967,6 +972,7 @@ int
|
||||||
cygwin_send (int fd, const void *buf, int len, unsigned int flags)
|
cygwin_send (int fd, const void *buf, int len, unsigned int flags)
|
||||||
{
|
{
|
||||||
fhandler_socket *h = (fhandler_socket *) dtable[fd];
|
fhandler_socket *h = (fhandler_socket *) dtable[fd];
|
||||||
|
sigframe thisframe (mainthread, 0);
|
||||||
|
|
||||||
int res = send (h->get_socket (), (const char *) buf, len, flags);
|
int res = send (h->get_socket (), (const char *) buf, len, flags);
|
||||||
if (res == SOCKET_ERROR)
|
if (res == SOCKET_ERROR)
|
||||||
|
@ -1353,6 +1359,7 @@ cygwin_rcmd (char **ahost, unsigned short inport, char *locuser,
|
||||||
{
|
{
|
||||||
int res = -1;
|
int res = -1;
|
||||||
SOCKET fd2s;
|
SOCKET fd2s;
|
||||||
|
sigframe thisframe (mainthread, 0);
|
||||||
|
|
||||||
int res_fd = dtable.find_unused_handle ();
|
int res_fd = dtable.find_unused_handle ();
|
||||||
if (res_fd == -1)
|
if (res_fd == -1)
|
||||||
|
@ -1392,6 +1399,7 @@ int
|
||||||
cygwin_rresvport (int *port)
|
cygwin_rresvport (int *port)
|
||||||
{
|
{
|
||||||
int res = -1;
|
int res = -1;
|
||||||
|
sigframe thisframe (mainthread, 0);
|
||||||
|
|
||||||
int res_fd = dtable.find_unused_handle ();
|
int res_fd = dtable.find_unused_handle ();
|
||||||
if (res_fd == -1)
|
if (res_fd == -1)
|
||||||
|
@ -1420,6 +1428,7 @@ cygwin_rexec (char **ahost, unsigned short inport, char *locuser,
|
||||||
{
|
{
|
||||||
int res = -1;
|
int res = -1;
|
||||||
SOCKET fd2s;
|
SOCKET fd2s;
|
||||||
|
sigframe thisframe (mainthread, 0);
|
||||||
|
|
||||||
int res_fd = dtable.find_unused_handle ();
|
int res_fd = dtable.find_unused_handle ();
|
||||||
if (res_fd == -1)
|
if (res_fd == -1)
|
||||||
|
@ -1597,6 +1606,7 @@ fhandler_socket::~fhandler_socket ()
|
||||||
int
|
int
|
||||||
fhandler_socket::read (void *ptr, size_t len)
|
fhandler_socket::read (void *ptr, size_t len)
|
||||||
{
|
{
|
||||||
|
sigframe thisframe (mainthread);
|
||||||
int res = recv (get_socket (), (char *) ptr, len, 0);
|
int res = recv (get_socket (), (char *) ptr, len, 0);
|
||||||
if (res == SOCKET_ERROR)
|
if (res == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
|
@ -1608,6 +1618,7 @@ fhandler_socket::read (void *ptr, size_t len)
|
||||||
int
|
int
|
||||||
fhandler_socket::write (const void *ptr, size_t len)
|
fhandler_socket::write (const void *ptr, size_t len)
|
||||||
{
|
{
|
||||||
|
sigframe thisframe (mainthread);
|
||||||
int res = send (get_socket (), (const char *) ptr, len, 0);
|
int res = send (get_socket (), (const char *) ptr, len, 0);
|
||||||
if (res == SOCKET_ERROR)
|
if (res == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
|
@ -1623,6 +1634,7 @@ int
|
||||||
fhandler_socket::close ()
|
fhandler_socket::close ()
|
||||||
{
|
{
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
sigframe thisframe (mainthread);
|
||||||
|
|
||||||
if (closesocket (get_socket ()))
|
if (closesocket (get_socket ()))
|
||||||
{
|
{
|
||||||
|
@ -1661,6 +1673,7 @@ fhandler_socket::ioctl (unsigned int cmd, void *p)
|
||||||
int res;
|
int res;
|
||||||
struct ifconf *ifc;
|
struct ifconf *ifc;
|
||||||
struct ifreq *ifr;
|
struct ifreq *ifr;
|
||||||
|
sigframe thisframe (mainthread);
|
||||||
|
|
||||||
switch (cmd)
|
switch (cmd)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1101,7 +1101,7 @@ mount_info::cygdrive_posix_path (const char *src, char *dst, int trailing_slash_
|
||||||
The cygdrive prefix always ends with a trailing slash so
|
The cygdrive prefix always ends with a trailing slash so
|
||||||
the drive letter is added after the path. */
|
the drive letter is added after the path. */
|
||||||
dst[len++] = tolower (src[0]);
|
dst[len++] = tolower (src[0]);
|
||||||
if (!src[2])
|
if (!src[2] || (SLASH_P (src[2]) && !src[3]))
|
||||||
dst[len++] = '\000';
|
dst[len++] = '\000';
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1136,10 +1136,16 @@ mount_info::conv_to_posix_path (const char *src_path, char *posix_path,
|
||||||
int keep_rel_p)
|
int keep_rel_p)
|
||||||
{
|
{
|
||||||
int src_path_len = strlen (src_path);
|
int src_path_len = strlen (src_path);
|
||||||
int trailing_slash_p = (src_path_len > 0
|
int relative_path_p = !isabspath (src_path);
|
||||||
&& SLASH_P (src_path[src_path_len - 1]));
|
int trailing_slash_p;
|
||||||
int relative_path_p = (! SLASH_P (*src_path)
|
|
||||||
&& strchr (src_path, ':') == NULL);
|
if (src_path_len <= 1)
|
||||||
|
trailing_slash_p = 0;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const char *lastchar = src_path + src_path_len - 1;
|
||||||
|
trailing_slash_p = SLASH_P (*lastchar) && lastchar[-1] != ':';
|
||||||
|
}
|
||||||
|
|
||||||
debug_printf ("conv_to_posix_path (%s, %s)", src_path,
|
debug_printf ("conv_to_posix_path (%s, %s)", src_path,
|
||||||
keep_rel_p ? "keep-rel" : "no-keep-rel");
|
keep_rel_p ? "keep-rel" : "no-keep-rel");
|
||||||
|
@ -1212,8 +1218,7 @@ mount_info::conv_to_posix_path (const char *src_path, char *posix_path,
|
||||||
caller must want an absolute path (otherwise we would have returned
|
caller must want an absolute path (otherwise we would have returned
|
||||||
above). So we always return an absolute path at this point. */
|
above). So we always return an absolute path at this point. */
|
||||||
if ((isalpha (pathbuf[0])) && (pathbuf[1] == ':'))
|
if ((isalpha (pathbuf[0])) && (pathbuf[1] == ':'))
|
||||||
cygdrive_posix_path (pathbuf, posix_path, trailing_slash_p &&
|
cygdrive_posix_path (pathbuf, posix_path, trailing_slash_p);
|
||||||
pathbuflen > 3);
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* The use of src_path and not pathbuf here is intentional.
|
/* The use of src_path and not pathbuf here is intentional.
|
||||||
|
|
|
@ -110,6 +110,7 @@ cygwin_select (int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
|
||||||
fd_set *dummy_readfds = allocfd_set (n);
|
fd_set *dummy_readfds = allocfd_set (n);
|
||||||
fd_set *dummy_writefds = allocfd_set (n);
|
fd_set *dummy_writefds = allocfd_set (n);
|
||||||
fd_set *dummy_exceptfds = allocfd_set (n);
|
fd_set *dummy_exceptfds = allocfd_set (n);
|
||||||
|
sigframe thisframe (mainthread, 0);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (n > FD_SETSIZE)
|
if (n > FD_SETSIZE)
|
||||||
|
|
|
@ -16,7 +16,6 @@ details. */
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "winsup.h"
|
#include "winsup.h"
|
||||||
#include "sync.h"
|
|
||||||
|
|
||||||
extern BOOL allow_ntsec;
|
extern BOOL allow_ntsec;
|
||||||
|
|
||||||
|
@ -101,7 +100,7 @@ Static waitq waitq_main; // Storage for main thread
|
||||||
|
|
||||||
muto NO_COPY *sync_proc_subproc = NULL; // Control access to subproc stuff
|
muto NO_COPY *sync_proc_subproc = NULL; // Control access to subproc stuff
|
||||||
|
|
||||||
DWORD NO_COPY maintid = 0; // ID of the main thread
|
sigthread NO_COPY mainthread; // ID of the main thread
|
||||||
DWORD NO_COPY sigtid = 0; // ID of the signal thread
|
DWORD NO_COPY sigtid = 0; // ID of the signal thread
|
||||||
|
|
||||||
int NO_COPY pending_signals = 0; // TRUE if signals pending
|
int NO_COPY pending_signals = 0; // TRUE if signals pending
|
||||||
|
@ -605,7 +604,7 @@ sigproc_init ()
|
||||||
to a signal handler function. */
|
to a signal handler function. */
|
||||||
signal_arrived = CreateEvent(&sec_none_nih, TRUE, FALSE, NULL);
|
signal_arrived = CreateEvent(&sec_none_nih, TRUE, FALSE, NULL);
|
||||||
|
|
||||||
maintid = GetCurrentThreadId ();// For use in determining if signals
|
mainthread.id = GetCurrentThreadId ();// For use in determining if signals
|
||||||
// should be blocked.
|
// should be blocked.
|
||||||
|
|
||||||
if (!(hwait_sig = makethread (wait_sig, NULL, 0, "sig")))
|
if (!(hwait_sig = makethread (wait_sig, NULL, 0, "sig")))
|
||||||
|
@ -719,10 +718,10 @@ sig_send (pinfo *p, int sig, DWORD ebp)
|
||||||
HANDLE thiscatch = NULL;
|
HANDLE thiscatch = NULL;
|
||||||
HANDLE thiscomplete = NULL;
|
HANDLE thiscomplete = NULL;
|
||||||
BOOL wait_for_completion;
|
BOOL wait_for_completion;
|
||||||
extern signal_dispatch sigsave;
|
sigframe thisframe;
|
||||||
|
|
||||||
if (p == myself_nowait_nonmain)
|
if (p == myself_nowait_nonmain)
|
||||||
p = (tid == maintid) ? myself : myself_nowait;
|
p = (tid == mainthread.id) ? myself : myself_nowait;
|
||||||
if (!(its_me = (p == NULL || p == myself || p == myself_nowait)))
|
if (!(its_me = (p == NULL || p == myself || p == myself_nowait)))
|
||||||
wait_for_completion = FALSE;
|
wait_for_completion = FALSE;
|
||||||
else
|
else
|
||||||
|
@ -751,7 +750,7 @@ sig_send (pinfo *p, int sig, DWORD ebp)
|
||||||
{
|
{
|
||||||
if (!wait_for_completion)
|
if (!wait_for_completion)
|
||||||
thiscatch = sigcatch_nosync;
|
thiscatch = sigcatch_nosync;
|
||||||
else if (tid != maintid)
|
else if (tid != mainthread.id)
|
||||||
{
|
{
|
||||||
thiscatch = sigcatch_nonmain;
|
thiscatch = sigcatch_nonmain;
|
||||||
thiscomplete = sigcomplete_nonmain;
|
thiscomplete = sigcomplete_nonmain;
|
||||||
|
@ -760,7 +759,7 @@ sig_send (pinfo *p, int sig, DWORD ebp)
|
||||||
{
|
{
|
||||||
thiscatch = sigcatch_main;
|
thiscatch = sigcatch_main;
|
||||||
thiscomplete = sigcomplete_main;
|
thiscomplete = sigcomplete_main;
|
||||||
sigsave.ebp = ebp ?: (DWORD) __builtin_frame_address (1);
|
thisframe.set (mainthread);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!(thiscatch = getsem (p, "sigcatch", 0, 0)))
|
else if (!(thiscatch = getsem (p, "sigcatch", 0, 0)))
|
||||||
|
@ -1262,7 +1261,7 @@ wait_sig (VOID *)
|
||||||
/* Signalled from a child process that it has stopped */
|
/* Signalled from a child process that it has stopped */
|
||||||
case __SIGCHILDSTOPPED:
|
case __SIGCHILDSTOPPED:
|
||||||
sip_printf ("Received child stopped notification");
|
sip_printf ("Received child stopped notification");
|
||||||
dispatched |= sig_handle (SIGCHLD, rc);
|
dispatched |= sig_handle (SIGCHLD);
|
||||||
if (proc_subproc (PROC_CHILDSTOPPED, 0))
|
if (proc_subproc (PROC_CHILDSTOPPED, 0))
|
||||||
dispatched |= 1;
|
dispatched |= 1;
|
||||||
break;
|
break;
|
||||||
|
@ -1270,7 +1269,7 @@ wait_sig (VOID *)
|
||||||
/* A normal UNIX signal */
|
/* A normal UNIX signal */
|
||||||
default:
|
default:
|
||||||
sip_printf ("Got signal %d", sig);
|
sip_printf ("Got signal %d", sig);
|
||||||
int wasdispatched = sig_handle (sig, rc);
|
int wasdispatched = sig_handle (sig);
|
||||||
dispatched |= wasdispatched;
|
dispatched |= wasdispatched;
|
||||||
if (sig == SIGCHLD && wasdispatched)
|
if (sig == SIGCHLD && wasdispatched)
|
||||||
dispatched_sigchld = 1;
|
dispatched_sigchld = 1;
|
||||||
|
@ -1293,14 +1292,11 @@ wait_sig (VOID *)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
SetEvent (sigcomplete_main);
|
SetEvent (sigcomplete_main);
|
||||||
sigproc_printf ("signalled sigcomplete_main %p", sigcomplete_main);
|
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
ReleaseSemaphore (sigcomplete_nonmain, 1, NULL);
|
ReleaseSemaphore (sigcomplete_nonmain, 1, NULL);
|
||||||
sigproc_printf ("signalled sigcomplete_nonmain %p", sigcomplete_nonmain);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sigproc_printf ("Did not signal anyone");
|
|
||||||
/* Signal from another process. No need to synchronize. */
|
/* Signal from another process. No need to synchronize. */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1367,3 +1363,29 @@ wait_subproc (VOID *)
|
||||||
sip_printf ("done");
|
sip_printf ("done");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
/* Provide a stack frame when calling WaitFor* functions */
|
||||||
|
|
||||||
|
#undef WaitForSingleObject
|
||||||
|
|
||||||
|
DWORD __stdcall
|
||||||
|
WFSO (HANDLE hHandle, DWORD dwMilliseconds)
|
||||||
|
{
|
||||||
|
DWORD ret;
|
||||||
|
sigframe thisframe (mainthread);
|
||||||
|
ret = WaitForSingleObject (hHandle, dwMilliseconds);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef WaitForMultipleObjects
|
||||||
|
|
||||||
|
DWORD __stdcall
|
||||||
|
WFMO (DWORD nCount, CONST HANDLE *lpHandles, BOOL fWaitAll, DWORD dwMilliseconds)
|
||||||
|
{
|
||||||
|
DWORD ret;
|
||||||
|
sigframe thisframe (mainthread);
|
||||||
|
ret = WaitForMultipleObjects (nCount, lpHandles, fWaitAll, dwMilliseconds);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -32,12 +32,60 @@ typedef struct struct_waitq
|
||||||
HANDLE thread_ev;
|
HANDLE thread_ev;
|
||||||
} waitq;
|
} waitq;
|
||||||
|
|
||||||
|
class muto;
|
||||||
|
|
||||||
|
struct sigthread
|
||||||
|
{
|
||||||
|
DWORD id;
|
||||||
|
DWORD frame;
|
||||||
|
muto *lock;
|
||||||
|
sigthread () : id (0), frame (0), lock (0) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
class sigframe
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
sigthread *st;
|
||||||
|
|
||||||
|
public:
|
||||||
|
void set (sigthread &t, int up = 1)
|
||||||
|
{
|
||||||
|
if (!t.lock)
|
||||||
|
t.lock = new_muto (FALSE, "sigthread");
|
||||||
|
t.lock->acquire ();
|
||||||
|
st = &t;
|
||||||
|
t.frame = (DWORD) (up ? __builtin_frame_address (1) :
|
||||||
|
__builtin_frame_address (0));
|
||||||
|
t.lock->release ();
|
||||||
|
}
|
||||||
|
|
||||||
|
sigframe () {st = NULL;}
|
||||||
|
sigframe (sigthread &t, int up = 1)
|
||||||
|
{
|
||||||
|
if (!t.frame || t.id == GetCurrentThreadId ())
|
||||||
|
set (t, up);
|
||||||
|
else
|
||||||
|
st = NULL;
|
||||||
|
}
|
||||||
|
~sigframe ()
|
||||||
|
{
|
||||||
|
if (st)
|
||||||
|
{
|
||||||
|
st->lock->acquire ();
|
||||||
|
st->frame = 0;
|
||||||
|
st->lock->release ();
|
||||||
|
st = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
extern sigthread mainthread;
|
||||||
extern HANDLE signal_arrived;
|
extern HANDLE signal_arrived;
|
||||||
|
|
||||||
BOOL __stdcall my_parent_is_alive ();
|
BOOL __stdcall my_parent_is_alive ();
|
||||||
extern "C" int __stdcall sig_dispatch_pending (int force = FALSE) __asm__ ("sig_dispatch_pending");
|
extern "C" int __stdcall sig_dispatch_pending (int force = FALSE) __asm__ ("sig_dispatch_pending");
|
||||||
extern "C" void __stdcall set_process_mask (sigset_t newmask);
|
extern "C" void __stdcall set_process_mask (sigset_t newmask);
|
||||||
int __stdcall sig_handle (int, int);
|
int __stdcall sig_handle (int);
|
||||||
void __stdcall sig_clear (int);
|
void __stdcall sig_clear (int);
|
||||||
void __stdcall sig_set_pending (int);
|
void __stdcall sig_set_pending (int);
|
||||||
int __stdcall handle_sigsuspend (sigset_t);
|
int __stdcall handle_sigsuspend (sigset_t);
|
||||||
|
@ -53,7 +101,6 @@ void __stdcall signal_fixup_after_fork ();
|
||||||
|
|
||||||
extern char myself_nowait_dummy[];
|
extern char myself_nowait_dummy[];
|
||||||
extern char myself_nowait_nonmain_dummy[];
|
extern char myself_nowait_nonmain_dummy[];
|
||||||
extern DWORD maintid;
|
|
||||||
extern HANDLE hExeced; // Process handle of new window
|
extern HANDLE hExeced; // Process handle of new window
|
||||||
// process created by spawn_guts()
|
// process created by spawn_guts()
|
||||||
|
|
||||||
|
|
|
@ -20,12 +20,11 @@ details. */
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "winsup.h"
|
#include "winsup.h"
|
||||||
#include "sync.h"
|
|
||||||
|
|
||||||
muto NO_COPY muto_start;
|
muto NO_COPY muto_start;
|
||||||
|
|
||||||
/* Constructor */
|
/* Constructor */
|
||||||
muto::muto(int inh, const char *s) : sync (0), visits(0), waiters(-1), tid (0), next (NULL)
|
muto::muto (int inh, const char *s) : sync (0), visits(0), waiters(-1), tid (0), next (NULL)
|
||||||
{
|
{
|
||||||
/* Create event which is used in the fallback case when blocking is necessary */
|
/* Create event which is used in the fallback case when blocking is necessary */
|
||||||
if (!(bruteforce = CreateEvent (inh ? &sec_all_nih : &sec_none_nih, FALSE, FALSE, name)))
|
if (!(bruteforce = CreateEvent (inh ? &sec_all_nih : &sec_none_nih, FALSE, FALSE, name)))
|
||||||
|
|
|
@ -47,7 +47,7 @@ extern muto muto_start;
|
||||||
/* Use a statically allocated buffer as the storage for a muto */
|
/* Use a statically allocated buffer as the storage for a muto */
|
||||||
#define new_muto(__inh, __name) \
|
#define new_muto(__inh, __name) \
|
||||||
({ \
|
({ \
|
||||||
static NO_COPY muto __mbuf; \
|
static __attribute__((section(".data_cygwin_nocopy"))) muto __mbuf; \
|
||||||
(void) new ((char *) &__mbuf) muto (__inh, __name); \
|
(void) new ((char *) &__mbuf) muto (__inh, __name); \
|
||||||
__mbuf.next = muto_start.next; \
|
__mbuf.next = muto_start.next; \
|
||||||
muto_start.next = &__mbuf; \
|
muto_start.next = &__mbuf; \
|
||||||
|
|
|
@ -184,6 +184,7 @@ static int
|
||||||
read_handler (int fd, void *ptr, size_t len)
|
read_handler (int fd, void *ptr, size_t len)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
sigframe thisframe (mainthread);
|
||||||
fhandler_base *fh = dtable[fd];
|
fhandler_base *fh = dtable[fd];
|
||||||
|
|
||||||
if (dtable.not_open (fd))
|
if (dtable.not_open (fd))
|
||||||
|
|
|
@ -705,7 +705,7 @@ __pthread_kill (pthread_t * thread, int sig)
|
||||||
if (item->sigs)
|
if (item->sigs)
|
||||||
myself->setthread2signal (item);
|
myself->setthread2signal (item);
|
||||||
|
|
||||||
int rval = sig_send (myself, sig);
|
int rval = _kill (myself->pid, sig);
|
||||||
|
|
||||||
// unlock myself
|
// unlock myself
|
||||||
return rval;
|
return rval;
|
||||||
|
|
|
@ -85,6 +85,7 @@ extern HANDLE hMainProc;
|
||||||
|
|
||||||
/* Now that pinfo has been defined, include... */
|
/* Now that pinfo has been defined, include... */
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
#include "sync.h"
|
||||||
#include "sigproc.h"
|
#include "sigproc.h"
|
||||||
#include "fhandler.h"
|
#include "fhandler.h"
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
@ -308,7 +309,6 @@ struct signal_dispatch
|
||||||
void (*func) (int);
|
void (*func) (int);
|
||||||
int sig;
|
int sig;
|
||||||
int saved_errno;
|
int saved_errno;
|
||||||
DWORD ebp;
|
|
||||||
DWORD oldmask;
|
DWORD oldmask;
|
||||||
DWORD retaddr;
|
DWORD retaddr;
|
||||||
DWORD *retaddr_on_stack;
|
DWORD *retaddr_on_stack;
|
||||||
|
|
Loading…
Reference in New Issue