help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Make does not clean up the target when stderr is piped. Why?


From: Masahiro Yamada
Subject: Make does not clean up the target when stderr is piped. Why?
Date: Fri, 4 Jun 2021 12:31:51 +0900

Hi.

GNU Make cleans up partially updated targets
if the user interrupts before the build rules complete.

If GNU Make does not do this, they will not be updated
in the next run of 'make' because their timestamps are
new while the contents are incomplete.

This issue was asked in the Linux kernel ML [1],
but I can reproduce it in simple test code.
Please see the following case.



[Sample Makefile]
test.txt:
        echo hello > $@
        sleep 10
        echo bye >> $@


Let's run 'make' and press Ctrl-C immediately.


[test1]
$ rm -f test.txt;  make
echo hello > test.txt
sleep 10
^Cmake: *** Deleting file 'test.txt'
make: *** [Makefile:3: test.txt] Interrupt


[test2]
$ rm -f test.txt;  make  | cat
echo hello > test.txt
sleep 10
^Cmake: *** Deleting file 'test.txt'
make: *** [Makefile:3: test.txt] Interrupt


[test3]
$ rm -f test.txt;  make  2>&1 | cat
echo hello > test.txt
sleep 10
^C


[test1] and [test2] clean up 'text.txt'.

[test3] immediately returns to the prompt
without any clean-up messages.
The incomplete 'test.txt' is left over.



[1] : 
https://lore.kernel.org/lkml/CAK7LNAQ73zG69F4hMJhgrHp8yT9tUmb-0tN=kFtWA98-YV3eNA@mail.gmail.com/T/#mf252f36e94da8b418070e2d5e1e43eef7df26998

-- 
Best Regards
Masahiro Yamada



reply via email to

[Prev in Thread] Current Thread [Next in Thread]