sd: remove 'ssd' driver support
[unleashed/tickless.git] / usr / src / lib / libast / common / obsolete / spawn.c
blob738653fcdb559036c856b9c8bc47aa677cdba08a
1 /***********************************************************************
2 * *
3 * This software is part of the ast package *
4 * Copyright (c) 1985-2010 AT&T Intellectual Property *
5 * and is licensed under the *
6 * Common Public License, Version 1.0 *
7 * by AT&T Intellectual Property *
8 * *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
12 * *
13 * Information and Software Systems Research *
14 * AT&T Research *
15 * Florham Park NJ *
16 * *
17 * Glenn Fowler <gsf@research.att.com> *
18 * David Korn <dgk@research.att.com> *
19 * Phong Vo <kpv@research.att.com> *
20 * *
21 ***********************************************************************/
22 #pragma prototyped
25 * OBSOLETE 20030321 -- use spawnveg()
28 #include <ast_lib.h>
30 #if !_lib_spawnve
31 #define spawnve ______spawnve
32 #endif
33 #if !_lib_spawnvpe
34 #define spawnvpe ______spawnvpe
35 #endif
36 #if !_lib_spawnvp
37 #define spawnvp ______spawnvp
38 #endif
39 #if !_lib_spawnlp
40 #define spawnlp ______spawnlp
41 #endif
43 #include <ast.h>
44 #include <error.h>
46 #if !_lib_spawnve
47 #undef spawnve
48 #endif
49 #if !_lib_spawnvpe
50 #undef spawnvpe
51 #endif
52 #if !_lib_spawnvp
53 #undef spawnvp
54 #endif
55 #if !_lib_spawnlp
56 #undef spawnlp
57 #endif
59 #if defined(__EXPORT__)
60 #define extern __EXPORT__
61 #endif
63 #if _lib_spawnve
65 NoN(spawnve)
67 #else
69 extern pid_t
70 spawnve(const char* cmd, char* const argv[], char* const envv[])
72 return spawnveg(cmd, argv, envv, 0);
75 #endif
77 #if _lib_spawnvpe
79 NoN(spawnvpe)
81 #else
83 extern pid_t
84 spawnvpe(const char* name, char* const argv[], char* const envv[])
86 register const char* path = name;
87 pid_t pid;
88 char buffer[PATH_MAX];
90 if (*path != '/')
91 path = pathpath(buffer, name, NULL, PATH_REGULAR|PATH_EXECUTE);
92 if ((pid = spawnve(path, argv, envv)) >= 0)
93 return pid;
94 if (errno == ENOEXEC)
96 register char** newargv;
97 register char** ov;
98 register char** nv;
100 for (ov = (char**)argv; *ov++;);
101 if (newargv = newof(0, char*, ov + 1 - (char**)argv, 0))
103 nv = newargv;
104 *nv++ = "sh";
105 *nv++ = (char*)path;
106 ov = (char**)argv;
107 while (*nv++ = *++ov);
108 path = pathshell();
109 pid = spawnve(path, newargv, environ);
110 free(newargv);
112 else
113 errno = ENOMEM;
115 return pid;
118 #endif
120 #if _lib_spawnvp
122 NoN(spawnvp)
124 #else
126 extern pid_t
127 spawnvp(const char* name, char* const argv[])
129 return spawnvpe(name, argv, environ);
132 #endif
134 #if _lib_spawnlp
136 NoN(spawnlp)
138 #else
140 extern pid_t
141 spawnlp(const char* name, const char* arg, ...)
143 va_list ap;
144 pid_t pid;
146 va_start(ap, arg);
147 pid = spawnvp(name, (char* const*)&arg);
148 va_end(ap);
149 return pid;
152 #endif