1 /* $Header: os2.c,v 3.0.1.2 90/11/10 01:42:38 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 3.0.1.2 90/11/10 01:42:38 lwall
10 * patch38: more msdos/os2 upgrades
12 * Revision 3.0.1.1 90/10/15 17:49:55 lwall
13 * patch29: Initial revision
15 * Revision 3.0.1.1 90/03/27 16:10:41 lwall
16 * patch16: MSDOS support
18 * Revision 1.1 90/03/18 20:32:01 dds
28 * Various Unix compatibility functions for OS/2
41 int ioctl(int handle, unsigned int function, char *data)
55 if ( path[0] != 0 && path[1] == ':' )
56 DosSelectDisk(toupper(path[0]) - '@');
64 int setpriority(int class, int pid, int val)
74 return DosSetPrty(flag ? PRTYS_PROCESSTREE : PRTYS_PROCESS, class, val, pid);
77 int getpriority(int which /* ignored */, int pid)
81 if ( DosGetPrty(PRTYS_PROCESS, &val, pid) )
88 /* get parent process id */
101 int kill(int pid, int sig)
115 DosKillProcess(flag ? DKP_PROCESSTREE : DKP_PROCESS, pid);
119 DosFlagProcess(pid, flag ? FLGP_SUBTREE : FLGP_PID, PFLG_A, 0);
123 DosFlagProcess(pid, flag ? FLGP_SUBTREE : FLGP_PID, PFLG_B, 0);
127 DosFlagProcess(pid, flag ? FLGP_SUBTREE : FLGP_PID, PFLG_C, 0);
134 /* Sleep function. */
138 DosSleep(len * 1000L);
141 /* Just pretend that everyone is a superuser */
162 * The following code is based on the do_exec and do_aexec functions
166 do_aspawn(really,arglast)
170 register STR **st = stack->ary_array;
171 register int sp = arglast[1];
172 register int items = arglast[2] - sp;
179 New(1101,argv, items+1, char*);
181 for (st += ++sp; items > 0; items--,st++) {
188 if (really && *(tmps = str_get(really)))
189 status = spawnvp(P_WAIT,tmps,argv);
191 status = spawnvp(P_WAIT,argv[0],argv);
197 char *getenv(char *name);
210 /* save an extra exec if possible */
211 if ((shell = getenv("COMSPEC")) == 0)
212 shell = "C:\\OS2\\CMD.EXE";
214 /* see if there are shell metacharacters in it */
215 if (strchr(cmd, '>') || strchr(cmd, '<') || strchr(cmd, '|')
216 || strchr(cmd, '&') || strchr(cmd, '^'))
218 return spawnl(P_WAIT,shell,shell,"/C",cmd,(char*)0);
220 New(1102,argv, strlen(cmd) / 2 + 2, char*);
222 New(1103,cmd2, strlen(cmd) + 1, char);
225 for (s = cmd2; *s;) {
226 while (*s && isspace(*s)) s++;
229 while (*s && !isspace(*s)) s++;
235 if ((status = spawnvp(P_WAIT,argv[0],argv)) == -1) {
248 printf("\nUsage: %s [-acdnpsSvw] [-Dnumber] [-i[extension]] [-Idirectory]"
250 printf("\nUsage: %s [-acdnpPsSuUvw] [-Dnumber] [-i[extension]] [-Idirectory]"
252 "\n [-e \"command\"] [-x[directory]] [filename] [arguments]\n", myname);
254 printf("\n -a autosplit mode with -n or -p"
255 "\n -c syntaxcheck only"
256 "\n -d run scripts under debugger"
257 "\n -n assume 'while (<>) { ...script... }' loop arround your script"
258 "\n -p assume loop like -n but print line also like sed"
260 "\n -P run script through C preprocessor befor compilation"
262 "\n -s enable some switch parsing for switches after script name"
263 "\n -S look for the script using PATH environment variable");
265 printf("\n -u dump core after compiling the script"
266 "\n -U allow unsafe operations");
268 printf("\n -v print version number and patchlevel of perl"
269 "\n -w turn warnings on for compilation of your script\n"
270 "\n -Dnumber set debugging flags"
271 "\n -i[extension] edit <> files in place (make backup if extension supplied)"
272 "\n -Idirectory specify include directory in conjunction with -P"
273 "\n -e command one line of script, multiple -e options are allowed"
274 "\n [filename] can be ommitted, when -e is used"
275 "\n -x[directory] strip off text before #!perl line and perhaps cd to directory\n");