diff options
author | Christopher Faylor <me@cgf.cx> | 2005-08-24 18:26:14 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2005-08-24 18:26:14 +0000 |
commit | 04dfd98dc6b216b24ff8efd98f4c0a96d15ae6d4 (patch) | |
tree | a38432e19a473f8fa329a93a5d617cd55bcc7691 /winsup/cygwin/spawn.cc | |
parent | b56c466b2cf4eb2492bad1343561c660238fff16 (diff) | |
download | cygnal-04dfd98dc6b216b24ff8efd98f4c0a96d15ae6d4.tar.gz cygnal-04dfd98dc6b216b24ff8efd98f4c0a96d15ae6d4.tar.bz2 cygnal-04dfd98dc6b216b24ff8efd98f4c0a96d15ae6d4.zip |
* spawn.cc (perhaps_suffix): Record errno-type error value in third argument.
(find_exec): On error, set errno returned from perhaps_suffix.
(spawn_guts): Ditto.
Diffstat (limited to 'winsup/cygwin/spawn.cc')
-rw-r--r-- | winsup/cygwin/spawn.cc | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index bb2fe7d32..39402182a 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -54,15 +54,24 @@ DWORD dwExeced; Returns (possibly NULL) suffix */ static const char * -perhaps_suffix (const char *prog, path_conv& buf) +perhaps_suffix (const char *prog, path_conv& buf, int& err) { char *ext; + err = 0; debug_printf ("prog '%s'", prog); - buf.check (prog, PC_SYM_FOLLOW, std_suffixes); + buf.check (prog, PC_SYM_FOLLOW | PC_NULLEMPTY, std_suffixes); - if (!buf.exists () || buf.isdir ()) - ext = NULL; + if (buf.isdir ()) + { + err = EACCES; + ext = NULL; + } + else if (!buf.exists ()) + { + err = ENOENT; + ext = NULL; + } else if (buf.known_suffix) ext = (char *) buf + (buf.known_suffix - buf.get_win32 ()); else @@ -90,12 +99,13 @@ find_exec (const char *name, path_conv& buf, const char *mywinenv, char tmp[CYG_MAX_PATH]; const char *posix = (opt & FE_NATIVE) ? NULL : name; bool has_slash = strchr (name, '/'); + int err; /* Check to see if file can be opened as is first. Win32 systems always check . first, but PATH may not be set up to do this. */ if ((has_slash || opt & FE_CWD) - && (suffix = perhaps_suffix (name, buf)) != NULL) + && (suffix = perhaps_suffix (name, buf, err)) != NULL) { if (posix && !has_slash) { @@ -149,7 +159,7 @@ find_exec (const char *name, path_conv& buf, const char *mywinenv, debug_printf ("trying %s", tmp); - if ((suffix = perhaps_suffix (tmp, buf)) != NULL) + if ((suffix = perhaps_suffix (tmp, buf, err)) != NULL) { if (posix == tmp) { @@ -181,6 +191,8 @@ find_exec (const char *name, path_conv& buf, const char *mywinenv, debug_printf ("%s = find_exec (%s)", (char *) buf, name); if (known_suffix) *known_suffix = suffix ?: strchr (buf, '\0'); + if (!retval && err) + set_errno (err); return retval; } @@ -450,10 +462,11 @@ spawn_guts (const char * prog_arg, const char *const *argv, goto skip_arg_parsing; } + int err; const char *ext; - if ((ext = perhaps_suffix (prog_arg, real_path)) == NULL) + if ((ext = perhaps_suffix (prog_arg, real_path, err)) == NULL) { - set_errno (ENOENT); + set_errno (err); res = -1; goto out; } |