diff options
author | Thomas White <taw@physics.org> | 2019-01-03 10:54:40 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2019-01-03 10:56:41 +0100 |
commit | b2286aca7040abff47afe07c12d741bb91441f63 (patch) | |
tree | 7d68482f23c257411821d1e37f631940a3c64b75 /src | |
parent | 1ccb8c35a27d1e714b8c3caacc1a68307ff12ada (diff) |
indexamajig: Return non-zero exit status if no patterns were processed
Diffstat (limited to 'src')
-rw-r--r-- | src/im-sandbox.c | 25 | ||||
-rw-r--r-- | src/im-sandbox.h | 6 | ||||
-rw-r--r-- | src/indexamajig.c | 10 |
3 files changed, 25 insertions, 16 deletions
diff --git a/src/im-sandbox.c b/src/im-sandbox.c index ad2bc5fc..0f57fd0c 100644 --- a/src/im-sandbox.c +++ b/src/im-sandbox.c @@ -955,9 +955,11 @@ char *create_tempdir(const char *temp_location) } -void create_sandbox(struct index_args *iargs, int n_proc, char *prefix, - int config_basename, FILE *fh, - Stream *stream, const char *tmpdir, int serial_start) +/* Returns the number of frames processed (not necessarily indexed). + * If the return value is zero, something is probably wrong. */ +int create_sandbox(struct index_args *iargs, int n_proc, char *prefix, + int config_basename, FILE *fh, + Stream *stream, const char *tmpdir, int serial_start) { int i; struct sandbox *sb; @@ -977,7 +979,7 @@ void create_sandbox(struct index_args *iargs, int n_proc, char *prefix, sb = calloc(1, sizeof(struct sandbox)); if ( sb == NULL ) { ERROR("Couldn't allocate memory for sandbox.\n"); - return; + return 0; } sb->n_processed_last_stats = 0; @@ -994,7 +996,7 @@ void create_sandbox(struct index_args *iargs, int n_proc, char *prefix, if ( setup_shm(sb) ) { ERROR("Failed to set up SHM.\n"); free(sb); - return; + return 0; } sb->shared->n_processed = 0; @@ -1007,7 +1009,7 @@ void create_sandbox(struct index_args *iargs, int n_proc, char *prefix, S_IRUSR | S_IWUSR, 0); if ( sb->queue_sem == SEM_FAILED ) { ERROR("Failed to create semaphore: %s\n", strerror(errno)); - return; + return 0; } sb->pids = calloc(n_proc, sizeof(pid_t)); @@ -1017,7 +1019,7 @@ void create_sandbox(struct index_args *iargs, int n_proc, char *prefix, || (sb->last_response == NULL) ) { ERROR("Couldn't allocate memory for PIDs.\n"); - return; + return 0; } /* Fill the queue */ @@ -1039,7 +1041,7 @@ void create_sandbox(struct index_args *iargs, int n_proc, char *prefix, r = sigaction(SIGCHLD, &sa, NULL); if ( r == -1 ) { ERROR("Failed to set signal handler!\n"); - return; + return 0; } /* Set up signal handler to clean up semaphore on exit */ @@ -1049,12 +1051,12 @@ void create_sandbox(struct index_args *iargs, int n_proc, char *prefix, r = sigaction(SIGINT, &sa, NULL); if ( r == -1 ) { ERROR("Failed to set signal handler!\n"); - return; + return 0; } r = sigaction(SIGQUIT, &sa, NULL); if ( r == -1 ) { ERROR("Failed to set signal handler!\n"); - return; + return 0; } taccs = time_accounts_init(); @@ -1145,9 +1147,12 @@ void create_sandbox(struct index_args *iargs, int n_proc, char *prefix, sb->shared->n_processed, sb->shared->n_hadcrystals, 100.0 * sb->shared->n_hadcrystals / sb->shared->n_processed, sb->shared->n_crystals); + r = sb->shared->n_processed; delete_temporary_folder(sb->tmpdir, n_proc); munmap(sb->shared, sizeof(struct sb_shm)); free(sb); + + return r; } diff --git a/src/im-sandbox.h b/src/im-sandbox.h index e5f3422b..eddced68 100644 --- a/src/im-sandbox.h +++ b/src/im-sandbox.h @@ -80,8 +80,8 @@ extern char *create_tempdir(const char *temp_location); extern void set_last_task(char *lt, const char *task); -extern void create_sandbox(struct index_args *iargs, int n_proc, char *prefix, - int config_basename, FILE *fh, Stream *stream, - const char *tempdir, int serial_start); +extern int create_sandbox(struct index_args *iargs, int n_proc, char *prefix, + int config_basename, FILE *fh, Stream *stream, + const char *tempdir, int serial_start); #endif /* IM_SANDBOX_H */ diff --git a/src/indexamajig.c b/src/indexamajig.c index f9b2c94d..f452b033 100644 --- a/src/indexamajig.c +++ b/src/indexamajig.c @@ -1288,8 +1288,8 @@ int main(int argc, char *argv[]) gsl_set_error_handler_off(); - create_sandbox(&iargs, n_proc, prefix, config_basename, fh, - st, tmpdir, serial_start); + r = create_sandbox(&iargs, n_proc, prefix, config_basename, fh, + st, tmpdir, serial_start); free_imagefile_field_list(iargs.copyme); cell_free(iargs.cell); @@ -1302,5 +1302,9 @@ int main(int argc, char *argv[]) close_stream(st); cleanup_indexing(iargs.ipriv); - return 0; + if ( r ) { + return 0; + } else { + return 1; /* No patterns processed */ + } } |