version 1.3, 1996/06/26 05:36:27 |
version 1.4, 1996/11/30 21:08:51 |
|
|
/* $OpenBSD$ */ |
/* $OpenBSD$ */ |
/* $NetBSD: compat.c,v 1.13 1995/11/22 17:40:00 christos Exp $ */ |
/* $NetBSD: compat.c,v 1.14 1996/11/06 17:59:01 christos Exp $ */ |
|
|
/* |
/* |
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California. |
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California. |
|
|
|
|
#ifndef lint |
#ifndef lint |
#if 0 |
#if 0 |
static char sccsid[] = "@(#)compat.c 5.7 (Berkeley) 3/1/91"; |
static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94"; |
#else |
#else |
static char rcsid[] = "$OpenBSD$"; |
static char rcsid[] = "$OpenBSD$"; |
#endif |
#endif |
|
|
int signo; |
int signo; |
{ |
{ |
GNode *gn; |
GNode *gn; |
|
|
if ((curTarg != NILGNODE) && !Targ_Precious (curTarg)) { |
if ((curTarg != NILGNODE) && !Targ_Precious (curTarg)) { |
char *p1; |
char *p1; |
char *file = Var_Value (TARGET, curTarg, &p1); |
char *file = Var_Value (TARGET, curTarg, &p1); |
|
|
char *cmd = (char *) cmdp; |
char *cmd = (char *) cmdp; |
GNode *gn = (GNode *) gnp; |
GNode *gn = (GNode *) gnp; |
|
|
/* |
/* |
* Avoid clobbered variable warnings by forcing the compiler |
* Avoid clobbered variable warnings by forcing the compiler |
* to ``unregister'' variables |
* to ``unregister'' variables |
*/ |
*/ |
|
|
* command? In any case, we warn the user that the command expanded to |
* command? In any case, we warn the user that the command expanded to |
* nothing (is this the right thing to do?). |
* nothing (is this the right thing to do?). |
*/ |
*/ |
|
|
if (*cmdStart == '\0') { |
if (*cmdStart == '\0') { |
free(cmdStart); |
free(cmdStart); |
Error("%s expands to empty string", cmd); |
Error("%s expands to empty string", cmd); |
|
|
|
|
while (isspace((unsigned char)*cmd)) |
while (isspace((unsigned char)*cmd)) |
cmd++; |
cmd++; |
|
|
/* |
/* |
* Search for meta characters in the command. If there are no meta |
* Search for meta characters in the command. If there are no meta |
* characters, there's no need to execute a shell to execute the |
* characters, there's no need to execute a shell to execute the |
|
|
if (noExecute) { |
if (noExecute) { |
return (0); |
return (0); |
} |
} |
|
|
if (*cp != '\0') { |
if (*cp != '\0') { |
/* |
/* |
* If *cp isn't the null character, we hit a "meta" character and |
* If *cp isn't the null character, we hit a "meta" character and |
|
|
av = brk_string(cmd, &argc, TRUE); |
av = brk_string(cmd, &argc, TRUE); |
av += 1; |
av += 1; |
} |
} |
|
|
local = TRUE; |
local = TRUE; |
|
|
/* |
/* |
|
|
} |
} |
free(cmdStart); |
free(cmdStart); |
Lst_Replace (cmdNode, (ClientData) NULL); |
Lst_Replace (cmdNode, (ClientData) NULL); |
|
|
/* |
/* |
* The child is off and running. Now all we can do is wait... |
* The child is off and running. Now all we can do is wait... |
*/ |
*/ |
|
|
break; |
break; |
} |
} |
} |
} |
|
|
if (stat > -1) { |
if (stat > -1) { |
if (WIFSTOPPED(reason)) { |
if (WIFSTOPPED(reason)) { |
status = WSTOPSIG(reason); /* stopped */ |
status = WSTOPSIG(reason); /* stopped */ |
|
|
} else { |
} else { |
status = WTERMSIG(reason); /* signaled */ |
status = WTERMSIG(reason); /* signaled */ |
printf ("*** Signal %d", status); |
printf ("*** Signal %d", status); |
} |
} |
|
|
|
|
if (!WIFEXITED(reason) || (status != 0)) { |
if (!WIFEXITED(reason) || (status != 0)) { |
if (errCheck) { |
if (errCheck) { |
gn->made = ERROR; |
gn->made = ERROR; |
|
|
if (p1) |
if (p1) |
free(p1); |
free(p1); |
} |
} |
|
|
/* |
/* |
* All the children were made ok. Now cmtime contains the modification |
* All the children were made ok. Now cmtime contains the modification |
* time of the newest child, we need to find out if we exist and when |
* time of the newest child, we need to find out if we exist and when |
|
|
* Make_DoAllVar(). |
* Make_DoAllVar(). |
*/ |
*/ |
Make_DoAllVar(gn); |
Make_DoAllVar(gn); |
|
|
/* |
/* |
* Alter our type to tell if errors should be ignored or things |
* Alter our type to tell if errors should be ignored or things |
* should not be printed so CompatRunCommand knows what to do. |
* should not be printed so CompatRunCommand knows what to do. |
|
|
|
|
return (0); |
return (0); |
} |
} |
|
|
/*- |
/*- |
*----------------------------------------------------------------------- |
*----------------------------------------------------------------------- |
* Compat_Run -- |
* Compat_Run -- |
|
|
gn = Targ_FindNode(".BEGIN", TARG_NOCREATE); |
gn = Targ_FindNode(".BEGIN", TARG_NOCREATE); |
if (gn != NILGNODE) { |
if (gn != NILGNODE) { |
Lst_ForEach(gn->commands, CompatRunCommand, (ClientData)gn); |
Lst_ForEach(gn->commands, CompatRunCommand, (ClientData)gn); |
|
if (gn->made == ERROR) { |
|
printf("\n\nStop.\n"); |
|
exit(1); |
|
} |
} |
} |
} |
} |
|
|