From 8ca13922fa32d2f95a9807d6e431190f7edd960c Mon Sep 17 00:00:00 2001 From: Moe Jette <jette1@llnl.gov> Date: Fri, 26 Jan 2007 01:29:40 +0000 Subject: [PATCH] Make slurmctld's working directory be same as SlurmctldLogFile (if any), otherwise StateSaveDir (which is likely a shared directory, possibly making core file identification more difficult). --- NEWS | 7 +++++-- src/slurmctld/controller.c | 29 +++++++++++++++++++---------- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/NEWS b/NEWS index 6b4316a72d8..a8d1488e713 100644 --- a/NEWS +++ b/NEWS @@ -1,12 +1,15 @@ This file describes changes in recent versions of SLURM. It primarily documents those changes that are of interest to users and admins. -* Changes in SLURM 1.2.0 -======================== +* Changes in SLURM 1.2.0-pre14 +============================== -- In sched/wiki2, clear required nodes list when a job is requeued. Note that the required node list is set to every node used when a job is started via sched/wiki2. -- BLUEGENE - Added display of deallocating blocks to smap and other tools. + -- Make slurmctld's working directory be same as SlurmctldLogFile (if any), + otherwise StateSaveDir (which is likely a shared directory, possibly + making core file identification more difficult). * Changes in SLURM 1.2.0-pre13 ============================== diff --git a/src/slurmctld/controller.c b/src/slurmctld/controller.c index 885b0a58eb3..4871eb09857 100644 --- a/src/slurmctld/controller.c +++ b/src/slurmctld/controller.c @@ -212,7 +212,7 @@ int main(int argc, char *argv[]) #endif /* !NDEBUG */ /* - * Create StateSaveLocation directory if necessary, and chdir() to it. + * Create StateSaveLocation directory if necessary. */ if (set_slurmctld_state_loc() < 0) fatal("Unable to initialize StateSaveLocation"); @@ -223,6 +223,24 @@ int main(int argc, char *argv[]) slurmctld_conf.slurmctld_logfile); if (error_code) error("daemon error %d", error_code); + if (slurmctld_conf.slurmctld_logfile + && (slurmctld_conf.slurmctld_logfile[0] == '/')) { + char *slash_ptr, *work_dir; + work_dir = xstrdup(slurmctld_conf.slurmctld_logfile); + slash_ptr = strrchr(work_dir, '/'); + if (slash_ptr == work_dir) + work_dir[1] = '\0'; + else + slash_ptr[0] = '\0'; + if (chdir(work_dir) < 0) + fatal("chdir(%s): %m", work_dir); + xfree(work_dir); + } else { + if (chdir(slurmctld_conf.state_save_location) < 0) { + fatal("chdir(%s): %m", + slurmctld_conf.state_save_location); + } + } } info("slurmctld version %s started", SLURM_VERSION); @@ -1198,14 +1216,5 @@ set_slurmctld_state_loc(void) (void) unlink(tmp); xfree(tmp); - /* - * Only chdir() to spool directory if slurmctld will be - * running as a daemon - */ - if (daemonize && chdir(slurmctld_conf.state_save_location) < 0) { - error("chdir(%s): %m", slurmctld_conf.state_save_location); - return SLURM_ERROR; - } - return SLURM_SUCCESS; } -- GitLab