Changeset 56


Ignore:
Timestamp:
01/08/12 17:21:05 (12 years ago)
Author:
mmamonski
Message:

handle job killing

Location:
trunk/pbs_drmaa
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/pbs_drmaa/job.c

    r55 r56  
    508508pbsdrmaa_job_read_exit_status( const char *job_id, const char *job_state_dir_prefix) 
    509509{ 
    510         char *status_file = NULL; 
     510        char *status_file = NULL, start_file = NULL; 
    511511        FILE *fhandle = NULL; 
    512512        int exit_status = -1; 
     
    515515 
    516516        status_file = fsd_asprintf("%s/%s.exitcode", job_state_dir_prefix, job_id); 
     517        start_file = fsd_asprintf("%s/%s.started", job_id, job_state_dir_prefix); 
    517518 
    518519        if ((fhandle = fopen(status_file, "r")) == NULL) 
    519520         { 
     521                struct stat tmpstat; 
     522 
    520523                fsd_log_error(("Failed to open job status file: %s", status_file)); 
     524                if (stat(start_file, &tmpstat) == 0 && (tmpstat.st_mode & S_IFREG)) 
     525                 { 
     526                        exit_status = 143; /* SIGTERM */ 
     527                        fsd_log_info("But start file exist %s. Assuming that job was killed (exit_status=%d).", start_file, exit_status); 
     528                 } 
    521529         } 
    522530        else 
     
    527535 
    528536        fsd_free(status_file); 
     537        fsd_free(start_file); 
    529538 
    530539        return exit_status; 
  • trunk/pbs_drmaa/submit.c

    r53 r56  
    336336                if( wd != NULL ) 
    337337                        script_len += strlen("cd ") + strlen(wd) + strlen("; "); 
     338                script_len += strlen("touch ") + strlen(((pbsdrmaa_session_t *)self->session)->job_exit_status_file_prefix) + strlen("/$PBS_JOBID.started;"); 
    338339                script_len += strlen(executable); 
    339340                if( argv != NULL ) 
     
    342343                if( input_path != NULL ) 
    343344                        script_len += strlen(" <") + strlen(input_path); 
    344                 if (((pbsdrmaa_session_t *)self->session)->job_exit_status_file_prefix) 
    345                         script_len += strlen("; echo $? >") + strlen(((pbsdrmaa_session_t *)self->session)->job_exit_status_file_prefix) + strlen("/$PBS_JOBID.exitcode"); 
     345 
     346                script_len += strlen("; echo $? >") + strlen(((pbsdrmaa_session_t *)self->session)->job_exit_status_file_prefix) + strlen("/$PBS_JOBID.exitcode"); 
    346347         } 
    347348 
     
    353354                if( wd != NULL ) 
    354355                        s += sprintf( s, "cd %s; ", wd ); 
     356                s += sprintf( s, "touch %s/$PBS_JOBID.started;", ((pbsdrmaa_session_t *)self->session)->job_exit_status_file_prefix) 
    355357                s += sprintf( s, "%s", executable ); 
    356358                if( argv != NULL ) 
     
    359361                if( input_path != NULL ) 
    360362                        s += sprintf( s, " <%s", input_path ); 
    361                 if (((pbsdrmaa_session_t *)self->session)->job_exit_status_file_prefix) 
    362                         s += sprintf( s, "; echo $? >%s/$PBS_JOBID.exitcode", ((pbsdrmaa_session_t *)self->session)->job_exit_status_file_prefix); 
     363 
     364                s += sprintf( s, "; echo $? >%s/$PBS_JOBID.exitcode", ((pbsdrmaa_session_t *)self->session)->job_exit_status_file_prefix); 
    363365 
    364366                fsd_assert( s == script+script_len ); 
Note: See TracChangeset for help on using the changeset viewer.