From: Greg Ercolano <erco@(email surpressed)>
Subject: [Q+A] submit-generic: not handling exit(2) [RETRY] correctly
   Date: Fri, 27 Oct 2006 18:28:39 -0400
Msg# 1415
View Complete Thread (1 article) | All Threads
Last Next
> I'm using submit-generic, and in the commands I'm submitting,
> I want to be able to use exit(2) to tell rush to requeue the frame
> given certain conditions.
>
> But for some reason, the submit-generic script is mapping all non-zero
> exit codes to cause a 'Fail'. eg:
>
> ###
> ### tahoe.128: 0001
> ###
> --------------- Rush 102.42a7 --------------
> [..]
> --   Command: perl //myserver/jobs/rushscripts/submit-generic.pl -render 1 0 perl
> [..]
> Executing the following in 'perl' (perl):
>     $|=1;
>     print "This is a test of a retry\n";
>     sleep(10);
>     exit(2);
>
> --- START
> This is a test of a retry
> --- FAILED: EXITCODE=2
>
> ..and the frame shows up as 'Fail', instead of 'Que'.


    Hmm, yes. 6 years and no one's noticed that, not even me!

    Looks like the submit-generic script isn't passing your exit code
    back to rush, it's short circuiting all non-zero exit codes to 1.

    It's a simple fix to the submit-generic.pl script. I'm surprised
    I never caught that.

    1) Find this block of lines in submit-generic.pl:

---- snip
    unless ( close(SHELL) )
    {
        my $exitcode = ( $? >> 8 );
        if ( $exitcode )
            { print STDERR "\n--- FAILED: EXITCODE=$exitcode\n"; exit(1); }
    }
---- snip

    2) Change those lines to instead read:

---- snip
    unless ( close(SHELL) )
    {
        my $exitcode = ( $? >> 8 );
        if ( $exitcode == 2 )
            { print "--- RETRY: EXIT CODE WAS $exitcode\n"; exit(2); }
        elsif ( $exitcode != 0 )
            { print "--- FAILED: EXIT CODE WAS $exitcode\n"; exit(1); }
        print STDERR "\n--- SUCCEEDED\n";
        exit(0);
    }
---- snip

    I'll include this fix in the next release of Rush: 102.42a8.

Last Next