From 07e657ed722b71b134c00ebf737c49d8163c7521 Mon Sep 17 00:00:00 2001 From: David Bigagli <david@schedmd.com> Date: Mon, 21 Jul 2014 16:09:07 -0700 Subject: [PATCH] Implement the scancel command to send the job string to slurmctld if no other command line options are specified. --- src/scancel/opt.c | 28 ++++++++++++++++++++++++++++ src/scancel/scancel.c | 9 +++++++-- src/scancel/scancel.h | 4 ++-- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/scancel/opt.c b/src/scancel/opt.c index 7b987a67ddf..4a29a5891fb 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 7d1f1aee106..d70f063c683 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 6f16cf974a1..82e925940d1 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 */ -- GitLab