aboutsummaryrefslogtreecommitdiff
path: root/src/ManualTerminationFile.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ManualTerminationFile.c')
-rw-r--r--src/ManualTerminationFile.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/ManualTerminationFile.c b/src/ManualTerminationFile.c
index 7e10a38..c1c3be3 100644
--- a/src/ManualTerminationFile.c
+++ b/src/ManualTerminationFile.c
@@ -2,12 +2,15 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
+#include <sys/stat.h>
#include "cctk.h"
#include "cctk_Arguments.h"
#include "cctk_Parameters.h"
#include "cctk_Termination.h"
-
+/* The termination file only lives on the root node, so the scheduled
+ * functions here always check that they are on that node.
+ */
enum{ BUFLEN = 128 };
/* On first call, pass parameter terminate_filename.
If it is null will construct file name in /tmp based on PBS_JOBID.
@@ -46,13 +49,15 @@ int ManualTermination_Init (CCTK_ARGUMENTS)
DECLARE_CCTK_ARGUMENTS;
DECLARE_CCTK_PARAMETERS;
- if (termination_from_file)
+ if (termination_from_file && CCTK_MyProc (cctkGH) == 0)
{
FILE *termfile = fopen (MT_get_terminate_filename (termination_file), "w");
if (termfile != NULL)
{
fprintf (termfile, "%d", 0);
fclose (termfile);
+ chmod(MT_get_terminate_filename (NULL),
+ S_IRUSR|S_IRGRP|S_IWUSR|S_IWGRP);
}
else
{
@@ -107,7 +112,9 @@ int ManualTermination_Cleanup (CCTK_ARGUMENTS)
{
DECLARE_CCTK_PARAMETERS;
- if (termination_from_file && MT_get_terminate_filename (NULL))
+ if (termination_from_file
+ && CCTK_MyProc (cctkGH) == 0
+ && MT_get_terminate_filename (NULL))
remove (MT_get_terminate_filename (NULL));
return 0;
}