aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2021-03-04 15:59:57 +0100
committerThomas White <taw@physics.org>2021-03-04 15:59:57 +0100
commitd76fc34958abfe4a5685f4a44b6b47c69975b313 (patch)
tree6838ca6fee68ef095d526ce438023ee239bbbf3e
parent6d5365e481543db9e3070225ebd7bc11a7562215 (diff)
SLURM: Cancel job by calling scancel
The API for cancelling a job seems to be Complicated. The source code for scancel is nearly a thousand lines long! The API also seems to have just changed. So, let's just run scancel and be done with it.
-rw-r--r--src/gui_backend_slurm.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/gui_backend_slurm.c b/src/gui_backend_slurm.c
index eb20beca..b09f7259 100644
--- a/src/gui_backend_slurm.c
+++ b/src/gui_backend_slurm.c
@@ -230,10 +230,20 @@ static int get_task_status(void *job_priv,
static void cancel_task(void *job_priv)
{
+ char jobid[128];
+ const gchar *args[3];
+ GError *error = NULL;
+ GSubprocess *sp;
struct slurm_job *job = job_priv;
- if ( slurm_kill_job(job->job_id, SIGINT, 0) ) {
- ERROR("Couldn't stop job: %s\n",
- slurm_strerror(slurm_get_errno()));
+
+ snprintf(jobid, 127, "%i", job->job_id);
+ args[0] = "scancel";
+ args[1] = jobid;
+ args[2] = NULL;
+ sp = g_subprocess_newv(args, G_SUBPROCESS_FLAGS_NONE, &error);
+ if ( sp == NULL ) {
+ ERROR("Failed to invoke scancel: %s\n", error->message);
+ g_error_free(error);
}
}