]> git.ipfire.org Git - thirdparty/make.git/commitdiff
[SV 62088] Avoid re-exec due to stdin.
authorDmitry Goncharov <dgoncharov@users.sf.net>
Sat, 26 Feb 2022 22:12:03 +0000 (17:12 -0500)
committerPaul Smith <psmith@gnu.org>
Sun, 27 Feb 2022 23:00:47 +0000 (18:00 -0500)
The fix for SV 60595 causes make to re-execute when the makefile is
read from stdin.  E.g.
    $ printf 'all:; $(info hello)' | make -sf -

Reported by Sergei Trofimovich <siarheit@google.com>
Test added by Paul Smith <psmith@gnu.org>

* src/main.c (main): Set the mtime of the stdin temporary file.
* tests/scripts/features/reinvoke: Add a test.

src/main.c
tests/scripts/features/reinvoke

index 0554e526267aa709de9ebde5ef4b12e8d9cfb860..206e3b337057aaa7c8bf41df6df310c89e2a14d3 100644 (file)
@@ -1849,6 +1849,8 @@ main (int argc, char **argv, char **envp)
                  make re-exec.  */
               f->intermediate = 0;
               f->dontcare = 0;
+              /* Avoid re-exec due to stdin.  */
+              f->last_mtime = f->mtime_before_update = f_mtime (f, 0);
             }
           }
     }
index cb3f2cc39d3c6c07e56d3e014a2fa46954db38c1..5bcc40b47e4cc2866a659a2a4eee394dbbce5d71 100644 (file)
@@ -163,5 +163,17 @@ include hello.d
 
 unlink('hello.td');
 
+# Test DV 62088 : make sure we don't re-invoke for stdin makefiles.
+# The test framework doesn't seem to have a good way to do this.
+
+create_file('input.mk', "all:;\$(info all)\n");
+
+close(STDIN);
+open(STDIN, "<", 'input.mk') || die "input.mk: $!\n";
+
+run_make_test('', '-sf -', "all\n");
+
+unlink('input.mk');
+
 # This tells the test driver that the perl test script executed properly.
 1;