diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2008-03-05 18:17:39 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2008-03-05 18:17:39 +0000 |
commit | 344d06119ea6c9488985e3ab0ba6531986de798e (patch) | |
tree | 25464d0474c2838037aa8edad0db696a79d3faed | |
parent | b90e16e6a7cc2149f0204b81f43bb90f9cc0955a (diff) | |
download | newlib-344d06119ea6c9488985e3ab0ba6531986de798e.zip newlib-344d06119ea6c9488985e3ab0ba6531986de798e.tar.gz newlib-344d06119ea6c9488985e3ab0ba6531986de798e.tar.bz2 |
2008-03-05 Corinna Vinschen <corinna@vinschen.de>
* child_info.h (~child_info_spawn): Check moreinfo->myself_pinfo for
NULL before closing.
* spawn.cc (spawn_guts): Don't close moreinfo->myself_pinfo explicitely
in case of failing CloseProcess.
* exceptions.cc (_cygtls::handle_exceptions): Replace top level SEH
installed by Windows with our own handler.
* fhandler.cc (fhandler_base::open_): Return EISDIR when trying to
create a directory.
(fhandler_base::open_9x): Ditto.
* ntdll.h (STATUS_OBJECT_NAME_INVALID): Define.
* path.cc (path_conv::check): If input path had a trailing dir
separator, tack it on to the native path if directory doesn't exist.
2008-03-05 Christopher Faylor <me+cygwin@cgf.cx>
* exceptions.cc (_cygtls::handle_exceptions): Detect when signal is
masked and treat as if it was not caught. Revert to a 'return 0'
rather than using a goto.
-rw-r--r-- | winsup/cygwin/ChangeLog | 23 | ||||
-rw-r--r-- | winsup/cygwin/child_info.h | 3 | ||||
-rw-r--r-- | winsup/cygwin/exceptions.cc | 17 | ||||
-rw-r--r-- | winsup/cygwin/fhandler.cc | 11 | ||||
-rw-r--r-- | winsup/cygwin/ntdll.h | 1 | ||||
-rw-r--r-- | winsup/cygwin/path.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/spawn.cc | 2 |
7 files changed, 51 insertions, 8 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 181c224..ca83a1d 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,26 @@ +2008-03-05 Corinna Vinschen <corinna@vinschen.de> + + * child_info.h (~child_info_spawn): Check moreinfo->myself_pinfo for + NULL before closing. + * spawn.cc (spawn_guts): Don't close moreinfo->myself_pinfo explicitely + in case of failing CloseProcess. + + * exceptions.cc (_cygtls::handle_exceptions): Replace top level SEH + installed by Windows with our own handler. + + * fhandler.cc (fhandler_base::open_): Return EISDIR when trying to + create a directory. + (fhandler_base::open_9x): Ditto. + * ntdll.h (STATUS_OBJECT_NAME_INVALID): Define. + * path.cc (path_conv::check): If input path had a trailing dir + separator, tack it on to the native path if directory doesn't exist. + +2008-03-05 Christopher Faylor <me+cygwin@cgf.cx> + + * exceptions.cc (_cygtls::handle_exceptions): Detect when signal is + masked and treat as if it was not caught. Revert to a 'return 0' + rather than using a goto. + 2008-03-04 Corinna Vinschen <corinna@vinschen.de> * dtable.cc (dtable::init_std_file_from_handle): Set access to diff --git a/winsup/cygwin/child_info.h b/winsup/cygwin/child_info.h index 19fefa7..d1553f7 100644 --- a/winsup/cygwin/child_info.h +++ b/winsup/cygwin/child_info.h @@ -125,7 +125,8 @@ public: cfree (*e); cfree (moreinfo->envp); } - CloseHandle (moreinfo->myself_pinfo); + if (moreinfo->myself_pinfo) + CloseHandle (moreinfo->myself_pinfo); cfree (moreinfo); } } diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index ce98d21..3dbd6e1 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -455,6 +455,8 @@ rtl_unwind (exception_list *frame, PEXCEPTION_RECORD e) /* Main exception handler. */ +extern exception_list *_except_list asm ("%fs:0"); + extern "C" char *__progname; int _cygtls::handle_exceptions (EXCEPTION_RECORD *e, exception_list *frame, CONTEXT *in, void *) @@ -586,7 +588,8 @@ _cygtls::handle_exceptions (EXCEPTION_RECORD *e, exception_list *frame, CONTEXT debug_printf ("In cygwin_except_handler exc %p at %p sp %p", e->ExceptionCode, in->Eip, in->Esp); debug_printf ("In cygwin_except_handler sig %d at %p", si.si_signo, in->Eip); - if (global_sigs[si.si_signo].sa_mask & SIGTOMASK (si.si_signo)) + bool masked = !!(me.sigmask & SIGTOMASK (si.si_signo)); + if (masked) syscall_printf ("signal %d, masked %p", si.si_signo, global_sigs[si.si_signo].sa_mask); @@ -605,8 +608,15 @@ _cygtls::handle_exceptions (EXCEPTION_RECORD *e, exception_list *frame, CONTEXT me.return_from_fault (); me.copy_context (in); - if (!cygwin_finished_initializing + + /* 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. */ + _except_list->handler = _cygtls::handle_exceptions; + + if (masked || &me == _sig_tls + || !cygwin_finished_initializing || (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) @@ -629,7 +639,7 @@ _cygtls::handle_exceptions (EXCEPTION_RECORD *e, exception_list *frame, CONTEXT if (try_to_debug (0)) { debugging = true; - goto out; + return 0; } rtl_unwind (frame, e); @@ -663,7 +673,6 @@ _cygtls::handle_exceptions (EXCEPTION_RECORD *e, exception_list *frame, CONTEXT sig_send (NULL, si, &me); // Signal myself me.incyg--; e->ExceptionFlags = 0; -out: return 0; } diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index bb54fe9..6f55182 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -538,6 +538,10 @@ fhandler_base::open_9x (int flags, mode_t mode) } else if (GetLastError () == ERROR_INVALID_HANDLE) set_errno (ENOENT); + else if (GetLastError () == ERROR_PATH_NOT_FOUND + && (flags & O_CREAT) + && get_win32_name ()[strlen (get_win32_name ()) - 1] == '\\') + set_errno (EISDIR); else __seterrno (); if (!nohandle ()) @@ -688,7 +692,12 @@ fhandler_base::open (int flags, mode_t mode) create_disposition, create_options, NULL, 0); if (!NT_SUCCESS (status)) { - __seterrno_from_nt_status (status); + /* Trying to create a directory should return EISDIR, not ENOENT. */ + if (status == STATUS_OBJECT_NAME_INVALID && (flags & O_CREAT) + && upath.Buffer[upath.Length / sizeof (WCHAR) - 1] == '\\') + set_errno (EISDIR); + else + __seterrno_from_nt_status (status); if (!nohandle ()) goto done; } diff --git a/winsup/cygwin/ntdll.h b/winsup/cygwin/ntdll.h index 2a71cd8..43d16ea 100644 --- a/winsup/cygwin/ntdll.h +++ b/winsup/cygwin/ntdll.h @@ -16,6 +16,7 @@ #define STATUS_INFO_LENGTH_MISMATCH ((NTSTATUS) 0xc0000004) #define STATUS_INVALID_PARAMETER ((NTSTATUS) 0xc000000d) #define STATUS_BUFFER_TOO_SMALL ((NTSTATUS) 0xc0000023) +#define STATUS_OBJECT_NAME_INVALID ((NTSTATUS) 0xc0000033) #define STATUS_WORKING_SET_QUOTA ((NTSTATUS) 0xc00000a1L) #define STATUS_INVALID_LEVEL ((NTSTATUS) 0xc0000148) #define STATUS_NO_MORE_FILES ((NTSTATUS)0x80000006L) diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 9187f86..59c0dc3 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -959,6 +959,8 @@ out: } else if (!need_directory || error) /* nothing to do */; + else if (fileattr == INVALID_FILE_ATTRIBUTES) + strcat (path, "\\"); else if (fileattr & FILE_ATTRIBUTE_DIRECTORY) path_flags &= ~PATH_SYMLINK; else diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index 3f446da..162e775 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -567,8 +567,6 @@ loop: myself->exec_sendsig = NULL; } res = -1; - if (moreinfo->myself_pinfo) - CloseHandle (moreinfo->myself_pinfo); goto out; } |