forked from mirrors/nixpkgs
make: Don't segfault if we can't get a tty name
This happened in VM builds: make flags: SHELL=/nix/store/dbxpkswwc7rh6g1iy6dwqklzw39hihb1-bash-4.3-p33/bin/bash /nix/store/jm26xg0h3jcrg4bbrwiqx3jpirscdk0p-stdenv/setup: line 658: 5957 Segmentation fault make ${makefile:+-f $makefile} ${enableParallelBuilding:+-j${NIX_BUILD_CORES} -l${NIX_BUILD_CORES}} $makeFlags "${makeFlagsArray[@]}" $buildFlags "${buildFlagsArray[@]}"
This commit is contained in:
parent
cb9429bd31
commit
3ede0a64a2
|
@ -17,6 +17,9 @@ stdenv.mkDerivation {
|
|||
# and /usr/lib. It's a stupid feature anyway. Likewise, when searching for
|
||||
# included Makefiles, don't look in /usr/include and friends.
|
||||
./impure-dirs.patch
|
||||
|
||||
# Don't segfault if we can't get a tty name.
|
||||
./no-tty-name.patch
|
||||
];
|
||||
|
||||
meta = {
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
From 292da6f6867b75a5af7ddbb639a1feae022f438f Mon Sep 17 00:00:00 2001
|
||||
From: Paul Smith <psmith@gnu.org>
|
||||
Date: Mon, 20 Oct 2014 05:54:56 +0000
|
||||
Subject: * main.c (main): [SV 43434] Handle NULL returns from ttyname().
|
||||
|
||||
---
|
||||
diff --git main.c main.c
|
||||
index b2d169c..0cdb8a8 100644
|
||||
--- main.c
|
||||
+++ main.c
|
||||
@@ -1429,13 +1429,18 @@ main (int argc, char **argv, char **envp)
|
||||
#ifdef HAVE_ISATTY
|
||||
if (isatty (fileno (stdout)))
|
||||
if (! lookup_variable (STRING_SIZE_TUPLE ("MAKE_TERMOUT")))
|
||||
- define_variable_cname ("MAKE_TERMOUT", TTYNAME (fileno (stdout)),
|
||||
- o_default, 0)->export = v_export;
|
||||
-
|
||||
+ {
|
||||
+ const char *tty = TTYNAME (fileno (stdout));
|
||||
+ define_variable_cname ("MAKE_TERMOUT", tty ? tty : DEFAULT_TTYNAME,
|
||||
+ o_default, 0)->export = v_export;
|
||||
+ }
|
||||
if (isatty (fileno (stderr)))
|
||||
if (! lookup_variable (STRING_SIZE_TUPLE ("MAKE_TERMERR")))
|
||||
- define_variable_cname ("MAKE_TERMERR", TTYNAME (fileno (stderr)),
|
||||
- o_default, 0)->export = v_export;
|
||||
+ {
|
||||
+ const char *tty = TTYNAME (fileno (stderr));
|
||||
+ define_variable_cname ("MAKE_TERMERR", tty ? tty : DEFAULT_TTYNAME,
|
||||
+ o_default, 0)->export = v_export;
|
||||
+ }
|
||||
#endif
|
||||
|
||||
/* Reset in case the switches changed our minds. */
|
||||
diff --git makeint.h makeint.h
|
||||
index 6223936..2009f41 100644
|
||||
--- makeint.h
|
||||
+++ makeint.h
|
||||
@@ -436,10 +436,11 @@ extern struct rlimit stack_limit;
|
||||
/* The number of bytes needed to represent the largest integer as a string. */
|
||||
#define INTSTR_LENGTH CSTRLEN ("18446744073709551616")
|
||||
|
||||
+#define DEFAULT_TTYNAME "true"
|
||||
#ifdef HAVE_TTYNAME
|
||||
# define TTYNAME(_f) ttyname (_f)
|
||||
#else
|
||||
-# define TTYNAME(_f) "true"
|
||||
+# define TTYNAME(_f) DEFAULT_TTYNAME
|
||||
#endif
|
||||
|
||||
|
||||
--
|
||||
cgit v0.9.0.2
|
Loading…
Reference in a new issue