Module Name: src Committed By: rillig Date: Sat Jul 13 15:10:06 UTC 2024
Modified Files: src/usr.bin/make/unit-tests: cmd-interrupt.exp cmd-interrupt.mk Log Message: tests/make: demonstrate interrupting make in compat mode To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/cmd-interrupt.exp cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/cmd-interrupt.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/make/unit-tests/cmd-interrupt.exp diff -u src/usr.bin/make/unit-tests/cmd-interrupt.exp:1.3 src/usr.bin/make/unit-tests/cmd-interrupt.exp:1.4 --- src/usr.bin/make/unit-tests/cmd-interrupt.exp:1.3 Sat Mar 18 22:20:12 2023 +++ src/usr.bin/make/unit-tests/cmd-interrupt.exp Sat Jul 13 15:10:06 2024 @@ -5,4 +5,5 @@ interrupt-ordinary: ok interrupt-phony: ok > cmd-interrupt-precious interrupt-precious: ok +interrupt-compat expected-fail exit status 0 Index: src/usr.bin/make/unit-tests/cmd-interrupt.mk diff -u src/usr.bin/make/unit-tests/cmd-interrupt.mk:1.4 src/usr.bin/make/unit-tests/cmd-interrupt.mk:1.5 --- src/usr.bin/make/unit-tests/cmd-interrupt.mk:1.4 Sat Mar 18 22:20:12 2023 +++ src/usr.bin/make/unit-tests/cmd-interrupt.mk Sat Jul 13 15:10:06 2024 @@ -1,4 +1,4 @@ -# $NetBSD: cmd-interrupt.mk,v 1.4 2023/03/18 22:20:12 sjg Exp $ +# $NetBSD: cmd-interrupt.mk,v 1.5 2024/07/13 15:10:06 rillig Exp $ # # Tests for interrupting a command. # @@ -17,10 +17,16 @@ # See also: # CompatDeleteTarget -all: clean-before interrupt-ordinary interrupt-phony interrupt-precious clean-after +all: clean-before +all: interrupt-ordinary +all: interrupt-phony +all: interrupt-precious +all: interrupt-compat +all: clean-after clean-before clean-after: .PHONY - @rm -f cmd-interrupt-ordinary cmd-interrupt-phony cmd-interrupt-precious + @rm -f cmd-interrupt-ordinary cmd-interrupt-phony + @rm -f cmd-interrupt-precious cmd-interrupt-compat interrupt-ordinary: @${.MAKE} ${MAKEFLAGS} -f ${MAKEFILE} cmd-interrupt-ordinary || true @@ -37,6 +43,10 @@ interrupt-precious: .PRECIOUS # The ././ is necessary to work around the file cache. @echo ${.TARGET}: ${exists(././cmd-interrupt-precious) :? ok : error } +interrupt-compat: + @${MAKE} -f ${MAKEFILE} cmd-interrupt-compat || true + @echo ${.TARGET} ${exists(././cmd-interrupt-compat) :? expected-fail : unexpected-ok } + cmd-interrupt-ordinary: > ${.TARGET} @kill -INT ${.MAKE.PID} @@ -48,3 +58,11 @@ cmd-interrupt-phony: .PHONY cmd-interrupt-precious: .PRECIOUS > ${.TARGET} @kill -INT ${.MAKE.PID} + +# When the make process (and not the process group) is interrupted in compat +# mode, it first tries to interrupt the process group of the currently running +# child command, but that fails since there is no such process group, rather +# the child command runs in the same process group as make itself. The child +# command then continues, and after sleeping a bit creates the target file. +cmd-interrupt-compat: + @kill -INT ${.MAKE.PID} && sleep 1 && > ${.TARGET}