Changeset 52


Ignore:
Timestamp:
01/07/12 21:21:29 (8 years ago)
Author:
mmamonski
Message:

store job exit status in file

Location:
trunk/pbs_drmaa
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/pbs_drmaa/session.c

    r45 r52  
    135135                                pbsdrmaa_exc_raise_pbs( "pbs_connect" ); 
    136136                 } 
     137 
     138                 self->job_exit_status_file_prefix = NULL; 
    137139         } 
    138140        EXCEPT_DEFAULT 
     
    159161                pbs_disconnect( pbsself->pbs_conn ); 
    160162        fsd_free( pbsself->status_attrl ); 
     163        fsd_free( pbsself->job_exit_status_file_prefix ); 
     164 
    161165        pbsself->super_destroy( self );  
    162166} 
     
    220224        fsd_conf_option_t *wait_thread_sleep_time = NULL; 
    221225        fsd_conf_option_t *max_retries_count = NULL; 
     226        fsd_conf_option_t *user_state_dir = NULL; 
    222227 
    223228        pbs_home = fsd_conf_dict_get(self->configuration, "pbs_home" ); 
    224229        wait_thread_sleep_time = fsd_conf_dict_get(self->configuration, "wait_thread_sleep_time" ); 
    225230        max_retries_count = fsd_conf_dict_get(self->configuration, "max_retries_count" ); 
     231        user_state_dir = fsd_conf_dict_get(self->configuration, "user_state_dir" ); 
    226232 
    227233        if( pbs_home && pbs_home->type == FSD_CONF_STRING ) 
     
    269275                fsd_log_info(("Wait thread sleep time: %d", pbsself->wait_thread_sleep_time)); 
    270276          } 
     277 
     278        if( user_state_dir && user_state_dir->type == FSD_CONF_STRING ) 
     279          { 
     280                struct passwd *pw = NULL; 
     281                uid_t uid; 
     282 
     283                uid = geteuid(); 
     284                pw = getpwuid(uid); /* drmaa_init is always called in thread safely fashion */ 
     285 
     286                if (!pw) 
     287                        fsd_exc_raise_fmt(FSD_ERRNO_INTERNAL_ERROR,"Failed to get pw_name of the user %d", uid); 
     288 
     289                pbsself->job_exit_status_file_prefix = fsd_asprintf(user_state_dir->val.string, pw->pw_name); 
     290          } 
     291        else 
     292          { 
     293                pbsself->job_exit_status_file_prefix = fsd_asprintf("%s/.drmaa", getenv("HOME")); 
     294          } 
     295 
     296        if (mkdir(pbsself->job_exit_status_file_prefix, 0600) == -1 && errno != EEXIST) /* TODO it would be much better to do stat before */ 
     297          { 
     298                fsd_log_warning("Failed to create job state directory: %s.  Valid job exit status may not be available in some cases.", pbsself->job_exit_status_file_prefix) 
     299          } 
     300 
     301 
     302        /* TODO purge old exit statuses files */ 
    271303 
    272304        pbsself->super_apply_configuration(self); /* call method from the superclass */ 
  • trunk/pbs_drmaa/session.h

    r45 r52  
    8484         */ 
    8585        int wait_thread_sleep_time; 
     86 
     87        /* 
     88         * The prefix of the directory where the job exit status information is stored (default: %HOME/.pbs-drmaa/ 
     89         */ 
     90        char *job_exit_status_file_prefix; 
    8691}; 
    8792 
  • trunk/pbs_drmaa/submit.c

    r49 r52  
    342342                if( input_path != NULL ) 
    343343                        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"); 
    344346         } 
    345347 
     
    357359                if( input_path != NULL ) 
    358360                        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 
    359364                fsd_assert( s == script+script_len ); 
    360365         } 
Note: See TracChangeset for help on using the changeset viewer.