0

I have an SCons setup which literally takes hours when run on a clean repository and performs a number of unrelated tasks, but should then be much faster when running on increments. The build-server kills SCons after an hour, assuming a stale build. This is fine for me, since it will periodically restart and eventually converge to a complete state.

However, this is based on the assumeption that after killing SCons I can just resume where it was killed and loose at most the task it was working on at that moment. But after such an event the .sconsign.dblite file is still of size zero, all targets are marked as not-current and not-built (although they actually exist on disk) and when restarting the build it does so from scratch.

I haven't found any documentation besides some year old discussions on the topic...

What is the intended behaviour and can it be configured?

mbschenkel
  • 1,865
  • 1
  • 18
  • 40

1 Answers1

1

SCons usually registers its own handlers for the signals SIGINT, SIGTERM and SIGHUP, where it will write the current signature info out to the sconsign file before finally terminating the process. I just made the experiment and ran a rather long SCons build (usually ~6min) and then interrupted it with a standard "kill " from another terminal. The result looks something like this under my Ubuntu Linux 14.04 LTS:

gcc -o d1_0/f00633_sconsbld_d1_0.o -c -Id1_0/lup000_sconsbld_d1_0 -Id1_0/lup001_sconsbld_d1_0 d1_0/f00633_sconsbld_d1_0.c
scons: Build interrupted.
scons: building terminated because of errors.
scons: writing .sconsign file.

and the sconsign file wasn't empty afterwards. This is the expected behaviour and if it doesn't work in your case, something's wrong. Is it possible that your build gets terminated by a SIGKILL instead?

dirkbaechle
  • 3,984
  • 14
  • 17
  • This is running on a Windows Server using Jenkins which says it uses the `TerminateProcess()` API. I feel that it is sometimes behaving as I would expect, but I have seen at leat one case where it didn't. – mbschenkel Sep 11 '15 at 06:39
  • When Jenkins uses TerminateProcess() it's a coincidence that you see the wanted behaviour at all. See https://msdn.microsoft.com/en-us/library/ms686722%28VS.85%29 , where it says: "If a process is terminated by TerminateProcess, all threads of the process are terminated immediately with no chance to run additional code. This means that the thread does not execute code in termination handler blocks." – dirkbaechle Sep 11 '15 at 08:59
  • In this case the question really boils down to how I can force SCons to periodically write the file out to disc. – mbschenkel Sep 11 '15 at 09:06
  • There currently is no option for this, you'd have to make a feature request or implement this yourself. Check http://scons.org/lists.php for getting in touch with the Core developers (start with the User ML please, you'll get redirected from there if required), or https://bitbucket.org/scons/scons/wiki/DeveloperGuide if you prefer to hack on this by yourself. – dirkbaechle Sep 11 '15 at 09:38
  • 1
    Another option might be to use a wrapper script that watches the SCons run itself, and kills it on a timeout before Jenkins takes any actions. See http://stackoverflow.com/questions/1191374/subprocess-with-timeout for example. – dirkbaechle Sep 11 '15 at 09:46