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-yv3...@mail.gmail.com/T/#mf252f36e94da8b418070e2d5e1e43eef7df26998

-- 
Best Regards
Masahiro Yamada

Reply via email to