aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/make/main.c
diff options
context:
space:
mode:
authorHartmut Brandt <harti@FreeBSD.org>2005-05-12 14:43:32 +0000
committerHartmut Brandt <harti@FreeBSD.org>2005-05-12 14:43:32 +0000
commit7007abaf14296b413a4b70cc32125132f469ccd2 (patch)
tree333a37dae1e63e44336b219fdceb7cb3b67946f7 /usr.bin/make/main.c
parent54a923046f34571ce044c02441d91a91171a30f7 (diff)
Notes
Diffstat (limited to 'usr.bin/make/main.c')
-rw-r--r--usr.bin/make/main.c82
1 files changed, 29 insertions, 53 deletions
diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c
index cb045895bea1..741c2f3799aa 100644
--- a/usr.bin/make/main.c
+++ b/usr.bin/make/main.c
@@ -73,7 +73,6 @@ __FBSDID("$FreeBSD$");
#include <sys/wait.h>
#include <err.h>
#include <errno.h>
-#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -617,16 +616,13 @@ chdir_verify_path(const char *path, char *obpath)
return (NULL);
}
-static void
-catch_child(int sig __unused)
-{
-}
-
-/*
- * In lieu of a good way to prevent every possible looping in
- * make(1), stop there from being more than MKLVL_MAXVAL processes forked
- * by make(1), to prevent a forkbomb from happening, in a dumb and
- * mechanical way.
+/**
+ * In lieu of a good way to prevent every possible looping in make(1), stop
+ * there from being more than MKLVL_MAXVAL processes forked by make(1), to
+ * prevent a forkbomb from happening, in a dumb and mechanical way.
+ *
+ * Side Effects:
+ * Creates or modifies enviornment variable MKLVL_ENVVAR via setenv().
*/
static void
check_make_level(void)
@@ -669,55 +665,31 @@ check_make_level(void)
int
main(int argc, char **argv)
{
+ const char *machine;
+ const char *machine_arch;
+ const char *machine_cpu;
Boolean outOfDate = TRUE; /* FALSE if all targets up to date */
char *p, *p1, *pathp;
char *path;
char mdpath[MAXPATHLEN];
char obpath[MAXPATHLEN];
char cdpath[MAXPATHLEN];
- const char *machine = getenv("MACHINE");
- const char *machine_arch = getenv("MACHINE_ARCH");
- const char *machine_cpu = getenv("MACHINE_CPU");
char *cp = NULL, *start;
- /* avoid faults on read-only strings */
- static char syspath[] = PATH_DEFSYSPATH;
-
- {
- /*
- * Catch SIGCHLD so that we get kicked out of select() when we
- * need to look at a child. This is only known to matter for the
- * -j case (perhaps without -P).
- *
- * XXX this is intentionally misplaced.
- */
- struct sigaction sa;
-
- sigemptyset(&sa.sa_mask);
- sa.sa_flags = SA_RESTART | SA_NOCLDSTOP;
- sa.sa_handler = catch_child;
- sigaction(SIGCHLD, &sa, NULL);
- }
-
check_make_level();
-#if DEFSHELL == 2
- /*
- * Turn off ENV to make ksh happier.
- */
- unsetenv("ENV");
-#endif
-
#ifdef RLIMIT_NOFILE
/*
* get rid of resource limit on file descriptors
*/
{
struct rlimit rl;
- if (getrlimit(RLIMIT_NOFILE, &rl) != -1 &&
- rl.rlim_cur != rl.rlim_max) {
- rl.rlim_cur = rl.rlim_max;
- setrlimit(RLIMIT_NOFILE, &rl);
+ if (getrlimit(RLIMIT_NOFILE, &rl) == -1) {
+ err(2, "getrlimit");
+ }
+ rl.rlim_cur = rl.rlim_max;
+ if (setrlimit(RLIMIT_NOFILE, &rl) == -1) {
+ err(2, "setrlimit");
}
}
#endif
@@ -750,23 +722,23 @@ main(int argc, char **argv)
* Note that while MACHINE is decided at run-time,
* MACHINE_ARCH is always known at compile time.
*/
- if (!machine) {
-#ifndef MACHINE
+ if ((machine = getenv("MACHINE")) == NULL) {
+#ifdef MACHINE
+ machine = MACHINE;
+#else
static struct utsname utsname;
if (uname(&utsname) == -1)
err(2, "uname");
machine = utsname.machine;
-#else
- machine = MACHINE;
#endif
}
- if (!machine_arch) {
-#ifndef MACHINE_ARCH
- machine_arch = "unknown";
-#else
+ if ((machine_arch = getenv("MACHINE_ARCH")) == NULL) {
+#ifdef MACHINE_ARCH
machine_arch = MACHINE_ARCH;
+#else
+ machine_arch = "unknown";
#endif
}
@@ -774,7 +746,7 @@ main(int argc, char **argv)
* Set machine_cpu to the minumum supported CPU revision based
* on the target architecture, if not already set.
*/
- if (!machine_cpu) {
+ if ((machine_cpu = getenv("MACHINE_CPU")) == NULL) {
if (!strcmp(machine_arch, "i386"))
machine_cpu = "i386";
else if (!strcmp(machine_arch, "alpha"))
@@ -805,6 +777,8 @@ main(int argc, char **argv)
* for the reading of inclusion paths and variable settings on the
* command line
*/
+ Proc_Init();
+
Dir_Init(); /* Initialize directory structures so -I flags
* can be processed correctly */
Var_Init(environ); /* As well as the lists of variables for
@@ -939,6 +913,8 @@ main(int argc, char **argv)
* as dir1:...:dirn) to the system include path.
*/
if (TAILQ_EMPTY(&sysIncPath)) {
+ char syspath[] = PATH_DEFSYSPATH;
+
for (start = syspath; *start != '\0'; start = cp) {
for (cp = start; *cp != '\0' && *cp != ':'; cp++)
continue;