X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=driver%2Fsubprocs.c;h=494f84614d3f20a0eaf2019a333b5ae3c23b52c5;hb=65740e2a8dea3d6309ae6e8914a0fb79e993ada8;hp=23eb0e44345bc4c979512285953fa33fbb49c61c;hpb=88134d551a9911995c013c5ed06a32c2b1044b85;p=xscreensaver diff --git a/driver/subprocs.c b/driver/subprocs.c old mode 100644 new mode 100755 index 23eb0e44..494f8461 --- a/driver/subprocs.c +++ b/driver/subprocs.c @@ -1,4 +1,4 @@ -/* xscreensaver, Copyright (c) 1991-1993 Jamie Zawinski +/* xscreensaver, Copyright (c) 1991-1993 Jamie Zawinski * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -60,8 +60,18 @@ #endif #include /* sys/resource.h needs this for timeval */ +#ifndef VMS #include /* for setpriority() and PRIO_PROCESS */ #include /* for waitpid() and associated macros */ +#else +#include "resource.h" +#include "wait.h" +#include +#define pid_t int +#define waitpid wait +#define fork vfork +#define random rand +#endif #include /* for the signal names */ extern char **environ; /* why isn't this in some header file? */ @@ -105,8 +115,12 @@ int nice_inferior = 0; extern Bool demo_mode_p; static void +#if __STDC__ +exec_screenhack (char *command) +#else exec_screenhack (command) char *command; +#endif { char *tmp; char buf [512]; @@ -144,21 +158,26 @@ exec_screenhack (command) what I've seen in Emacs, dealing with process groups isn't especially portable.) */ +#ifndef VMS tmp = command; command = (char *) malloc (strlen (tmp) + 6); memcpy (command, "exec ", 5); memcpy (command + 5, tmp, strlen (tmp) + 1); +#endif /* Invoke the shell as "/bin/sh -c 'exec prog -arg -arg ...'" */ + +#ifndef VMS av [ac++] = shell; av [ac++] = "-c"; +#endif av [ac++] = command; av [ac++] = 0; if (verbose_p) printf ("%s: spawning \"%s\" in pid %d.\n", progname, command, getpid ()); -#if defined(SYSV) || defined(SVR4) || defined(__hpux) +#if defined(SYSV) || defined(SVR4) || defined(__hpux) || defined(VMS) { int old_nice = nice (0); int n = nice_inferior - old_nice; @@ -189,7 +208,11 @@ exec_screenhack (command) /* Now overlay the current process with /bin/sh running the command. If this returns, it's an error. */ +#ifndef VMS execve (av [0], av, environ); +#else + system(command); +#endif sprintf (buf, "%s: %sexecve() failed", progname, (verbose_p ? "## " : "")); perror (buf); @@ -203,8 +226,12 @@ static Bool suspending = False; static char *current_hack_name P((void)); static void +#if __STDC__ +await_child_death (Bool killed) +#else await_child_death (killed) Bool killed; +#endif { Bool suspended_p = False; int status; @@ -212,6 +239,9 @@ await_child_death (killed) killing = 1; if (! pid) return; +#ifdef VMS + return; +#else do { @@ -277,6 +307,7 @@ await_child_death (killed) killing = 0; if (suspended_p != True) pid = 0; +#endif /* VMS */ } static char * @@ -426,6 +457,7 @@ suspend_screenhack (suspend_p) suspending = suspend_p; if (! pid) ; +#ifndef VMS else if (kill (pid, (suspend_p ? SIGSTOP : SIGCONT)) < 0) { char buf [255]; @@ -438,6 +470,7 @@ suspend_screenhack (suspend_p) else if (verbose_p) printf ("%s: %s pid %d.\n", progname, (suspend_p ? "suspending" : "resuming"), pid); +#endif } @@ -509,8 +542,10 @@ hack_environment () i = strlen (buf); s = (char *) malloc (i+1); strncpy (s, buf, i+1); +#ifndef VMS if (putenv (s)) abort (); +#endif }