1 /* $Header: os2.c,v 4.0 91/03/20 01:36:21 lwall Locked $
3 * (C) Copyright 1989, 1990 Diomidis Spinellis.
5 * You may distribute under the terms of the GNU General Public License
6 * as specified in the README file that comes with the perl 3.0 kit.
9 * Revision 4.0 91/03/20 01:36:21 lwall
12 * Revision 3.0.1.2 90/11/10 01:42:38 lwall
13 * patch38: more msdos/os2 upgrades
15 * Revision 3.0.1.1 90/10/15 17:49:55 lwall
16 * patch29: Initial revision
18 * Revision 3.0.1.1 90/03/27 16:10:41 lwall
19 * patch16: MSDOS support
21 * Revision 1.1 90/03/18 20:32:01 dds
31 * Various Unix compatibility functions for OS/2
44 int ioctl(int handle, unsigned int function, char *data)
58 if ( path[0] != 0 && path[1] == ':' )
59 DosSelectDisk(toupper(path[0]) - '@');
67 int setpriority(int class, int pid, int val)
77 return DosSetPrty(flag ? PRTYS_PROCESSTREE : PRTYS_PROCESS, class, val, pid);
80 int getpriority(int which /* ignored */, int pid)
84 if ( DosGetPrty(PRTYS_PROCESS, &val, pid) )
91 /* get parent process id */
104 int kill(int pid, int sig)
118 DosKillProcess(flag ? DKP_PROCESSTREE : DKP_PROCESS, pid);
122 DosFlagProcess(pid, flag ? FLGP_SUBTREE : FLGP_PID, PFLG_A, 0);
126 DosFlagProcess(pid, flag ? FLGP_SUBTREE : FLGP_PID, PFLG_B, 0);
130 DosFlagProcess(pid, flag ? FLGP_SUBTREE : FLGP_PID, PFLG_C, 0);
137 /* Sleep function. */
141 DosSleep(len * 1000L);
144 /* Just pretend that everyone is a superuser */
165 * The following code is based on the do_exec and do_aexec functions
169 do_aspawn(really,arglast)
173 register STR **st = stack->ary_array;
174 register int sp = arglast[1];
175 register int items = arglast[2] - sp;
182 New(1101,argv, items+1, char*);
184 for (st += ++sp; items > 0; items--,st++) {
191 if (really && *(tmps = str_get(really)))
192 status = spawnvp(P_WAIT,tmps,argv);
194 status = spawnvp(P_WAIT,argv[0],argv);
200 char *getenv(char *name);
213 /* save an extra exec if possible */
214 if ((shell = getenv("COMSPEC")) == 0)
215 shell = "C:\\OS2\\CMD.EXE";
217 /* see if there are shell metacharacters in it */
218 if (strchr(cmd, '>') || strchr(cmd, '<') || strchr(cmd, '|')
219 || strchr(cmd, '&') || strchr(cmd, '^'))
221 return spawnl(P_WAIT,shell,shell,"/C",cmd,(char*)0);
223 New(1102,argv, strlen(cmd) / 2 + 2, char*);
225 New(1103,cmd2, strlen(cmd) + 1, char);
228 for (s = cmd2; *s;) {
229 while (*s && isspace(*s)) s++;
232 while (*s && !isspace(*s)) s++;
238 if ((status = spawnvp(P_WAIT,argv[0],argv)) == -1) {
251 printf("\nUsage: %s [-acdnpsSvw] [-0[octal]] [-Dnumber] [-i[extension]] [-Idirectory]"
253 printf("\nUsage: %s [-acdnpPsSuUvw] [-Dnumber] [-i[extension]] [-Idirectory]"
255 "\n [-e \"command\"] [-x[directory]] [filename] [arguments]\n", myname);
257 printf("\n -a autosplit mode with -n or -p"
258 "\n -c syntaxcheck only"
259 "\n -d run scripts under debugger"
260 "\n -n assume 'while (<>) { ...script... }' loop arround your script"
261 "\n -p assume loop like -n but print line also like sed"
263 "\n -P run script through C preprocessor befor compilation"
265 "\n -s enable some switch parsing for switches after script name"
266 "\n -S look for the script using PATH environment variable");
268 printf("\n -u dump core after compiling the script"
269 "\n -U allow unsafe operations");
271 printf("\n -v print version number and patchlevel of perl"
272 "\n -w turn warnings on for compilation of your script\n"
273 "\n -0[octal] specify record separator (0, if no argument)"
274 "\n -Dnumber set debugging flags (argument is a bit mask)"
275 "\n -i[extension] edit <> files in place (make backup if extension supplied)"
276 "\n -Idirectory specify include directory in conjunction with -P"
277 "\n -e command one line of script, multiple -e options are allowed"
278 "\n [filename] can be ommitted, when -e is used"
279 "\n -x[directory] strip off text before #!perl line and perhaps cd to directory\n");