Skip to content

Inconsistent build state after interrupting with Ctrl-C #2718

Open

Description

@bdbaddog

This issue was originally created at: 2010-11-22 14:53:54.
This issue was reported by: klimkin.
klimkin said at 2010-11-22 14:53:54

Target files are not removed if job is interrupted. This leads to inconsistent state on rebuilds.

% cat SConstruct

CacheDir('cache')
env = Environment()
env.Command('out.h', [], """
        echo incomplete > $TARGET;
        sleep 2;
        echo complete > $TARGET
        """)

Instructions to reproduce:

% scons out.h
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
echo incomplete > out.h;
sleep 2;
rm -echo complete > out.h
scons: done building targets.
 
% cat out.h
complete
 
% rm -f out.h
 
% scons out.h --no-cache
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
echo incomplete > out.h;
sleep 2;                                <== Ctrl-C
scons: *** [out.h] Build interrupted.
scons: Build interrupted.
scons: building terminated because of errors.
scons: writing .sconsign file.
 
% cat out.h 
incomplete
 
% scons out.h 
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: `out.h' is up to date.
scons: done building targets.
 
% cat out.h 
incomplete

klimkin said at 2010-11-22 14:57:02

Created an attachment (id=817)
sources

klimkin said at 2010-11-22 15:22:58

Created an attachment (id=818)
Proposed patch

klimkin said at 2011-09-06 17:26:33

Created an attachment (id=869)
A better cleanup using t.remove()

klimkin said at 2011-09-06 17:30:58

Raising priority to match other issues.

bdbaddog said at 2011-09-06 19:38:59

Priority is set by the release team.

klimkin said at 2011-09-08 18:43:40

Created an attachment (id=873)
Don't clean if Exit called explicitly, ignore exceptions.

garyo said at 2012-09-01 10:01:49

Bumping all old issues targeted for past releases to 2.x.

klimkin said at 2016-05-19 16:15:26

bump

klimkin attached bug_ctrl_c.tbz2 at 2010-11-22 14:57:02.

sources

klimkin attached bug_ctrl_c.patch.gz at 2010-11-22 15:22:57.

Proposed patch

klimkin attached interrupted_build_cleanup.patch at 2011-09-06 17:26:33.

A better cleanup using t.remove()

klimkin attached interrupted_build_cleanup_v3.patch at 2011-09-08 18:43:40.

Don't clean if Exit called explicitly, ignore exceptions.

Activity

  1. added this to the 2.x milestone on Jan 2, 2018
  2. added
    has patch
    on Jan 9, 2021
  3. modified the milestones: 2.x, anytime on Mar 27, 2021
  4. mwichmann commented on Oct 25, 2025

    @mwichmann
    Collaborator

    Now I've finally read this in detail - the Action is to write to the file that will be the target, sleep, then replace it with different contents. If interrupted in between, the initial file is kept. So essentially it's showing what recent issue #4747 is talking about. If we consider interrupting an action while it's sleeping as a "failure" then, indeed, the target is not removed on failure. This is a contrived case to get a simple reproducer but I'm not sure SCons sees the Command action as "failing" in this case.

    This has nothing to do with sconsign getting corruptest, so my mention of this issue in #2144 was in error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions