From ae37cc121868a4554b5118c8ad45f5493333b39e Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Wed, 14 Sep 2005 23:03:44 +0000 Subject: [PATCH] * spawn.cc (av::error): Eliminate. (av::av): Remove reference to error. (av::replace0_maybe): Ditto. (av::dup_maybe): Ditto. (av::dup_all): Ditto. (av::unshift): Ditto. (spawn_guts): On a fault, return E2BIG only if ENOMEM has been set. Otherwise return EFAULT. --- winsup/cygwin/ChangeLog | 11 +++++++++++ winsup/cygwin/spawn.cc | 38 ++++++++++++++++---------------------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 9fb967f33..693976766 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,14 @@ +2005-09-14 Christopher Faylor + + * spawn.cc (av::error): Eliminate. + (av::av): Remove reference to error. + (av::replace0_maybe): Ditto. + (av::dup_maybe): Ditto. + (av::dup_all): Ditto. + (av::unshift): Ditto. + (spawn_guts): On a fault, return E2BIG only if ENOMEM has been set. + Otherwise return EFAULT. + 2005-09-14 Christopher Faylor * cygtls.h (san): New structure. diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index d419e3c07..14231dd5a 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -289,11 +289,10 @@ class av char **argv; int calloced; public: - int error; int argc; bool win16_exe; av (): argv (NULL) {} - av (int ac_in, const char * const *av_in) : calloced (0), error (false), argc (ac_in), win16_exe (false) + av (int ac_in, const char * const *av_in) : calloced (0), argc (ac_in), win16_exe (false) { argv = (char **) cmalloc (HEAP_1_ARGV, (argc + 5) * sizeof (char *)); memcpy (argv, av_in, (argc + 1) * sizeof (char *)); @@ -316,23 +315,21 @@ class av void replace0_maybe (const char *arg0) { /* Note: Assumes that argv array has not yet been "unshifted" */ - if (!calloced - && (argv[0] = cstrdup1 (arg0))) - calloced = true; - else - error = errno; + if (!calloced) + { + argv[0] = cstrdup1 (arg0); + calloced = true; + } } void dup_maybe (int i) { - if (i >= calloced - && !(argv[i] = cstrdup1 (argv[i]))) - error = errno; + if (i >= calloced) + argv[i] = cstrdup1 (argv[i]); } void dup_all () { for (int i = calloced; i < argc; i++) - if (!(argv[i] = cstrdup1 (argv[i]))) - error = errno; + argv[i] = cstrdup1 (argv[i]); } int fixup (child_info_types, const char *, path_conv&, const char *); }; @@ -356,10 +353,9 @@ av::unshift (const char *what, int conv) *p = '\0'; what = buf; } - if (!(*argv = cstrdup1 (what))) - error = errno; - argc++; + *argv = cstrdup1 (what); calloced++; + argc++; return 1; } @@ -433,8 +429,12 @@ spawn_guts (const char * prog_arg, const char *const *argv, STARTUPINFO si = {0, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL}; myfault efault; - if (efault.faulted (E2BIG)) + if (efault.faulted ()) { + if (get_errno () == ENOMEM) + set_errno (E2BIG); + else + set_errno (EFAULT); res = -1; goto out; } @@ -552,12 +552,6 @@ spawn_guts (const char * prog_arg, const char *const *argv, char *envblock; newargv.all_calloced (); - if (newargv.error) - { - set_errno (newargv.error); - return -1; - } - moreinfo->argc = newargv.argc; moreinfo->argv = newargv;