diff --git a/src/scancel/opt.c b/src/scancel/opt.c index 7b987a67ddf252d28803d5648ee69fd7effe2c96..4a29a5891fbed6d8df374d3709c84c3043b13564 100644 --- a/src/scancel/opt.c +++ b/src/scancel/opt.c @@ -151,6 +151,33 @@ int initialize_and_process_args(int argc, char *argv[]) } +/* has_default_opt() + * + * No getopt() options were specified, only the + * job ids is on the command line. + * + */ +bool +has_default_opt(void) +{ + if (opt.account == NULL + && opt.batch == false + && opt.interactive == false + && opt.job_name == NULL + && opt.partition == NULL + && opt.qos == NULL + && opt.reservation == NULL + && opt.signal == (uint16_t) - 1 + && opt.state == JOB_END + && opt.user_id == 0 + && opt.user_name == NULL + && opt.wckey == NULL + && opt.nodelist == NULL) { + return true; + } + return false; +} + static uint16_t _xlate_state_name(const char *state_name, bool env_var) { @@ -223,6 +250,7 @@ static void _opt_default(void) #endif opt.interactive = false; opt.job_cnt = 0; + opt.job_list = NULL; opt.job_name = NULL; opt.nodelist = NULL; opt.partition = NULL; diff --git a/src/scancel/scancel.c b/src/scancel/scancel.c index 7d1f1aee1064ce886c8a4e2d0ddc972d16efe1ea..d70f063c683e5c9be3edd0bf88c5c1e97d9b8e9a 100644 --- a/src/scancel/scancel.c +++ b/src/scancel/scancel.c @@ -150,7 +150,10 @@ _proc_cluster(void) int filter_cnt = 0; int rc; - _signal_job_by_str(); + if (has_default_opt()) { + rc = _signal_job_by_str(); + return rc; + } _load_job_records(); rc = _verify_job_ids(); @@ -172,7 +175,9 @@ _proc_cluster(void) return rc; } -/* _load_job_records - load all job information for filtering and verification */ +/* _load_job_records - load all job information for filtering + * and verification + */ static void _load_job_records (void) { diff --git a/src/scancel/scancel.h b/src/scancel/scancel.h index 6f16cf974a1487ef939155d3c48be698bef108fe..82e925940d19b7e59a54e8075666fea5744c1b1f 100644 --- a/src/scancel/scancel.h +++ b/src/scancel/scancel.h @@ -78,6 +78,6 @@ opt_t opt; * 3. update options with commandline args * 4. perform some verification that options are reasonable */ -int initialize_and_process_args(int argc, char *argv[]); - +extern int initialize_and_process_args(int argc, char *argv[]); +extern bool has_default_opt(void); #endif /* _HAVE_SCANCEL_H */