On 04/26/12 08:31, Marc Espie wrote:
> On Wed, Apr 25, 2012 at 11:34:24PM -0400, Alan Corey wrote:
>> I've seen this before, I wonder if there's some environment variable
>> I can set to stop it?
> 
> Nope.
> 
>> I try make fetch on a port, it fails due to a bad site.  I hit
>> Ctrl-C to stop it, it goes to the next site and downloads the file.
>> Then it deletes the file when it finishes.  I type make install and
>> it tries the bad site again...
> 
> That's the way make works. Don't hit ^C.
> 
> Changing this is impossible, since make sees the ^C, being the controlling
> process and all.

Hmmm, but still, if the process is interrupted, it should not continue
processing the rest of them, if the result is to be discarded anyway.
I believe this comes from a few places where we trap a few signals,
including SIGINT, to perform various cleanup operations. Those should,
apart from the cleanup, also exit the process, like the default SIGINT
handler would.

In the diff below, I put the cleanup in the "EXIT signal handler",
while the rest of the trapped signals merely do 'exit 1', triggering
the EXIT handler, but exiting the process with a non-zero exit code.

Fixes (as in immediately exists, and performs the appropriate cleanup)
the OP's example. Also contains the same change to all the traps in the
ports makefiles, but I only tested the OP's case, as I'm not sure where
the other cases are used.

OK?

/Alexander

Index: bsd.port.mk
===================================================================
RCS file: /cvs/ports/infrastructure/mk/bsd.port.mk,v
retrieving revision 1.1164
diff -u -p -r1.1164 bsd.port.mk
--- bsd.port.mk 22 Apr 2012 10:39:48 -0000      1.1164
+++ bsd.port.mk 26 Apr 2012 22:28:00 -0000
@@ -1528,7 +1528,9 @@ _DO_LOCK = \
 .  endfor
 
 _SIMPLE_LOCK = \
-       ${_LOCK}; locked=true; trap 'if $$locked; then ${_UNLOCK}; 
locked=false; fi' 0 1 2 3 13 15
+       ${_LOCK}; locked=true; \
+       trap 'if $$locked; then ${_UNLOCK}; locked=false; fi' 0; \
+       trap 'exit 1' 1 2 3 13 15
 
 .endif
 _SIMPLE_LOCK ?= :
@@ -2809,13 +2811,15 @@ describe:
 
 readme:
        @tmpdir=`mktemp -d ${TMPDIR}/readme.XXXXXX`; \
-       trap "rm -r $$tmpdir" 0 1 2 3 13 15; \
+       trap "rm -r $$tmpdir" 0; \
+       trap 'exit 1' 1 2 3 13 15; \
        cd ${.CURDIR} && PKGPATH=${PKGPATH} ${MAKE} TMPDIR=$$tmpdir 
README_NAME=${README_NAME} \
                ${READMES_TOP}/${PKGPATH}/${FULLPKGNAME${SUBPACKAGE}}.html
 
 readmes:
        @tmpdir=`mktemp -d ${TMPDIR}/readme.XXXXXX`; \
-       trap "rm -r $$tmpdir" 0 1 2 3 13 15; \
+       trap "rm -r $$tmpdir" 0; \
+       trap 'exit 1' 1 2 3 13 15; \
        cd ${.CURDIR} && PKGPATH=${PKGPATH} ${MAKE} TMPDIR=$$tmpdir 
README_NAME=${README_NAME} \
                ${_READMES}
 
Index: bsd.port.subdir.mk
===================================================================
RCS file: /cvs/ports/infrastructure/mk/bsd.port.subdir.mk,v
retrieving revision 1.106
diff -u -p -r1.106 bsd.port.subdir.mk
--- bsd.port.subdir.mk  17 Feb 2012 07:41:22 -0000      1.106
+++ bsd.port.subdir.mk  26 Apr 2012 22:28:00 -0000
@@ -193,7 +193,8 @@ clean:
 readmes:
        @${_subdir_fragment}
        @tmpdir=`mktemp -d ${TMPDIR}/readme.XXXXXX`; \
-       trap 'rm -r $$tmpdir' 0 1 2 3 13 15; \
+       trap 'rm -r $$tmpdir' 0; \
+       trap 'exit 1' 1 2 3 13 15; \
        cd ${.CURDIR} && ${MAKE} TMPDIR=$$tmpdir \
                ${READMES_TOP}/${PKGPATH}/README.html
 
Index: pkgpath.mk
===================================================================
RCS file: /cvs/ports/infrastructure/mk/pkgpath.mk,v
retrieving revision 1.44
diff -u -p -r1.44 pkgpath.mk
--- pkgpath.mk  17 Feb 2012 07:40:35 -0000      1.44
+++ pkgpath.mk  26 Apr 2012 22:28:00 -0000
@@ -95,7 +95,8 @@ _depfile_fragment = \
        case X$${_DEPENDS_FILE} in \
                X) _DEPENDS_FILE=`mktemp ${TMPDIR}/depends.XXXXXXXXX|| exit 1`; 
\
                export _DEPENDS_FILE; \
-               trap "rm -f $${_DEPENDS_FILE}" 0 1 2 3 13 15;; \
+               trap "rm -f $${_DEPENDS_FILE}" 0; \
+               trap 'exit 1' 1 2 3 13 15;; \
        esac
 
 # the cache may be filled in as root, so try to remove as normal user, THEN
@@ -104,7 +105,8 @@ _cache_fragment = \
        case X$${_DEPENDS_CACHE} in \
                X) _DEPENDS_CACHE=`mktemp -d ${TMPDIR}/dep_cache.XXXXXXXXX|| 
exit 1`; \
                export _DEPENDS_CACHE; \
-               trap "rm -rf 2>/dev/null $${_DEPENDS_CACHE} || ${SUDO} rm -rf 
$${_DEPENDS_CACHE}" 0 1 2 3 13 15;; \
+               trap "rm -rf 2>/dev/null $${_DEPENDS_CACHE} || ${SUDO} rm -rf 
$${_DEPENDS_CACHE}" 0; \
+               trap 'exit 1' 1 2 3 13 15;; \
        esac; PKGPATH=${PKGPATH}; export PKGPATH
 
 HTMLIFY =      sed -e 's/&/\&amp;/g' -e 's/>/\&gt;/g' -e 's/</\&lt;/g'

Reply via email to