7 #undef USE_DYNAMIC_LOADING
14 * pp_system() implemented via spawn()
15 * - more efficient and useful when embedding Perl in non-Cygwin apps
16 * - code mostly borrowed from djgpp.c
19 do_spawnvp (const char *path, const char * const *argv)
22 Sigsave_t ihand,qhand;
23 int childpid, result, status;
25 rsignal_save(SIGINT, SIG_IGN, &ihand);
26 rsignal_save(SIGQUIT, SIG_IGN, &qhand);
27 childpid = spawnvp(_P_NOWAIT,path,argv);
31 Perl_warner(aTHX_ WARN_EXEC,"Can't spawn \"%s\": %s",
32 path,Strerror (errno));
35 result = wait4pid(childpid, &status, 0);
36 } while (result == -1 && errno == EINTR);
40 (void)rsignal_restore(SIGINT, &ihand);
41 (void)rsignal_restore(SIGQUIT, &qhand);
46 do_aspawn (SV *really, void **mark, void **sp)
50 char **a,*tmps,**argv;
55 a=argv=(char**) alloca ((sp-mark+3)*sizeof (char*));
59 *a++ = SvPVx(*mark, n_a);
64 if (argv[0][0] != '/' && argv[0][0] != '\\'
65 && !(argv[0][0] && argv[0][1] == ':'
66 && (argv[0][2] == '/' || argv[0][2] != '\\'))
67 ) /* will swawnvp use PATH? */
68 TAINT_ENV(); /* testing IFS here is overkill, probably */
70 if (really && *(tmps = SvPV(really, n_a)))
71 rc=do_spawnvp (tmps,(const char * const *)argv);
73 rc=do_spawnvp (argv[0],(const char *const *)argv);
82 char **a,*s,*metachars = "$&*(){}[]'\";\\?>|<~`\n";
83 const char *command[4];
85 while (*cmd && isSPACE(*cmd))
88 if (strnEQ (cmd,"/bin/sh",7) && isSPACE (cmd[7]))
91 /* save an extra exec if possible */
92 /* see if there are shell metacharacters in it */
93 if (strstr (cmd,"..."))
95 if (*cmd=='.' && isSPACE (cmd[1]))
97 if (strnEQ (cmd,"exec",4) && isSPACE (cmd[4]))
99 for (s=cmd; *s && isALPHA (*s); s++) ; /* catch VAR=val gizmo */
104 if (strchr (metachars,*s))
106 if (*s=='\n' && s[1]=='\0')
117 return do_spawnvp("sh",command);
120 New (1303,PL_Argv,(s-cmd)/2+2,char*);
121 PL_Cmd=savepvn (cmd,s-cmd);
123 for (s=PL_Cmd; *s;) {
124 while (*s && isSPACE (*s)) s++;
127 while (*s && !isSPACE (*s)) s++;
135 return do_spawnvp(PL_Argv[0],(const char * const *)PL_Argv);
138 /* see also Cwd.pm */
146 Perl_croak(aTHX_ "Usage: Cwd::cwd()");
147 if((cwd = getcwd(NULL, -1))) {
148 ST(0) = sv_2mortal(newSVpv(cwd, 0));
150 #ifndef INCOMPLETE_TAINTS
161 char *file = __FILE__;
164 newXS("Cwd::cwd", Cygwin_cwd, file);