Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2000-04-26 09:13:32 +0400
committerChristopher Faylor <me@cgf.cx>2000-04-26 09:13:32 +0400
commit55fc91b9d62bec29deaba79e4adb4e85c35cc306 (patch)
tree149fe493e1a30834ca2dd732e5f30d01f0675c91 /winsup/cygwin/spawn.cc
parent47eaa6c421031e7f908eb352ebe6905b2d8bcb27 (diff)
* exceptions.cc (interruptible): Allocate slightly more space for directory
name check. Windows 95 seems to null-terminate the directory otherwise. (interrupt_on_return): Issue a fatal error if we can't find the caller's stack. * spawn.cc (find_exec): Accept a path_conv argument rather than a buffer so that the caller can find things out about a translated path. (perhaps_suffix): Ditto. (spawn_guts): Allocate path_conv stuff here so that we can find out stuff about the translated path (this is work in progress). * environ.cc (environ_init): Accept an as-yet unused argument indicating whether we were invoked from a cygwin parent or not. (winenv): Ditto. (posify): Accept an argument indicating whether the path has already been translated. * dlfcn.cc (check_access): Provide a path_conv buffer to find_exec. * exec.cc (sexecvpe): Ditto. * path.cc (path_conv::check): Rename from path_conv::path_conv. (mount_item::getmntent): Recognize "Cygwin executable" bit. (symlink_info::check): Remove debugging statements. * path.h (class path_conv): Add iscygexec method. Rewrite constructor to call "check" method to allow multiple operations on a path_conv variable. * pinfo.cc (pinfo_init): Pass argument to environ_init. * shared.h: Bump PROC_MAGIC. * winsup.h: Reflect above changes to function arguments. * include/sys/mount.h: Add MOUNT_CYGWIN_EXEC type.
Diffstat (limited to 'winsup/cygwin/spawn.cc')
-rw-r--r--winsup/cygwin/spawn.cc33
1 files changed, 14 insertions, 19 deletions
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
index e1a191c7b..2a3c95c77 100644
--- a/winsup/cygwin/spawn.cc
+++ b/winsup/cygwin/spawn.cc
@@ -38,22 +38,21 @@ suffix_info std_suffixes[] =
Returns (possibly NULL) suffix */
static const char *
-perhaps_suffix (const char *prog, char *buf)
+perhaps_suffix (const char *prog, path_conv &buf)
{
char *ext;
debug_printf ("prog '%s'", prog);
- path_conv temp (prog, SYMLINK_FOLLOW, 1, std_suffixes);
- strcpy (buf, temp.get_win32 ());
+ buf.check (prog, SYMLINK_FOLLOW, 1, std_suffixes);
- if (temp.file_attributes () & FILE_ATTRIBUTE_DIRECTORY)
+ if (buf.file_attributes () & FILE_ATTRIBUTE_DIRECTORY)
ext = NULL;
- else if (temp.known_suffix)
- ext = buf + (temp.known_suffix - temp.get_win32 ());
+ else if (buf.known_suffix)
+ ext = buf + (buf.known_suffix - buf.get_win32 ());
else
ext = strchr (buf, '\0');
- debug_printf ("buf %s, suffix found '%s'", buf, ext);
+ debug_printf ("buf %s, suffix found '%s'", (char *) buf, ext);
return ext;
}
@@ -66,7 +65,7 @@ perhaps_suffix (const char *prog, char *buf)
is undefined and NULL is returned. */
const char * __stdcall
-find_exec (const char *name, char *buf, const char *mywinenv,
+find_exec (const char *name, path_conv& buf, const char *mywinenv,
int null_if_notfound, const char **known_suffix)
{
const char *suffix = "";
@@ -120,10 +119,10 @@ errout:
if (null_if_notfound)
retval = NULL;
else
- strcpy (buf, path_conv (name).get_win32 ());
+ buf.check (name);
out:
- debug_printf ("%s = find_exec (%s)", buf, name);
+ debug_printf ("%s = find_exec (%s)", (char *) buf, name);
if (known_suffix)
*known_suffix = suffix ?: strchr (buf, '\0');
return retval;
@@ -257,7 +256,7 @@ spawn_guts (HANDLE hToken, const char * prog_arg, const char *const *argv,
/* nothing */;
char *real_path;
- char real_path_buf[MAX_PATH];
+ path_conv real_path_buf;
linebuf one_line;
@@ -274,15 +273,13 @@ spawn_guts (HANDLE hToken, const char * prog_arg, const char *const *argv,
goto skip_arg_parsing;
}
- MALLOC_CHECK;
-
real_path = real_path_buf;
const char *saved_prog_arg;
const char *newargv0, **firstarg;
const char *ext;
- if ((ext = perhaps_suffix (prog_arg, real_path)) == NULL)
+ if ((ext = perhaps_suffix (prog_arg, real_path_buf)) == NULL)
{
set_errno (ENOENT);
return -1;
@@ -381,7 +378,7 @@ spawn_guts (HANDLE hToken, const char * prog_arg, const char *const *argv,
one_line.prepend (" \"", 2);
}
- find_exec (pgm, real_path, "PATH=", 0, &ext);
+ find_exec (pgm, real_path_buf, "PATH=", 0, &ext);
cygwin_conv_to_posix_path (real_path, buf2);
one_line.prepend (buf2, strlen (buf2));
@@ -500,10 +497,8 @@ skip_arg_parsing:
if (mode == _P_DETACH || !set_console_state_for_spawn ())
flags |= DETACHED_PROCESS;
- MALLOC_CHECK;
/* Build windows style environment list */
- char *envblock = winenv (envp);
- MALLOC_CHECK;
+ char *envblock = winenv (envp, 0);
/* Preallocated buffer for `sec_user' call */
char sa_buf[1024];
@@ -977,6 +972,6 @@ int
spawnvpe (int mode, const char *file, const char * const *argv,
const char * const *envp)
{
- char buf[MAXNAMLEN];
+ path_conv buf;
return _spawnve (NULL, mode, find_exec (file, buf), argv, envp);
}