aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/man/indexamajig.14
-rw-r--r--src/im-sandbox.c40
2 files changed, 39 insertions, 5 deletions
diff --git a/doc/man/indexamajig.1 b/doc/man/indexamajig.1
index 91352f3e..c3f1adac 100644
--- a/doc/man/indexamajig.1
+++ b/doc/man/indexamajig.1
@@ -303,10 +303,6 @@ When using \fB--peaks=hdf5\fR, the peaks will be put through the same checks as
Without this option, peaks will be predicted in each pattern based on the crystal orientation from autoindexing and the parameters in the beam description file. With this option, indices will be assigned to the peaks found by the peak search, and the positions of those peaks used for the final integration stage.
.SH BUGS
-Don't run more than one indexamajig jobs simultaneously in the same working
-directory - they'll overwrite each other's DirAx or MOSFLM files, causing subtle
-problems which can't easily be detected.
-.PP
ReAx indexing is experimental. It works very nicely for some people, and crashes for others. In a future version, it will be improved and fully supported.
.SH AUTHOR
diff --git a/src/im-sandbox.c b/src/im-sandbox.c
index 8da42d32..aeeb023c 100644
--- a/src/im-sandbox.c
+++ b/src/im-sandbox.c
@@ -47,6 +47,7 @@
#include <sys/wait.h>
#include <fcntl.h>
#include <signal.h>
+#include <sys/stat.h>
#ifdef HAVE_CLOCK_GETTIME
#include <time.h>
@@ -187,13 +188,17 @@ static void process_image(const struct index_args *iargs,
struct hdfile *hdfile;
struct image image;
int i;
+ char filename[1024];
+
+ /* Prefix to jump out of temporary folder */
+ snprintf(filename, 1023, "../../%s", pargs->filename);
image.features = NULL;
image.data = NULL;
image.flags = NULL;
image.copyme = iargs->copyme;
image.id = cookie;
- image.filename = pargs->filename;
+ image.filename = filename;
image.beam = iargs->beam;
image.det = iargs->det;
image.crystals = NULL;
@@ -580,6 +585,35 @@ static void *run_reader(void *sbv)
}
+static int create_temporary_folder(signed int n)
+{
+ int r;
+ char tmp[64];
+
+ if ( n < 0 ) {
+ snprintf(tmp, 63, "indexamajig.%i", getpid());
+ } else {
+ snprintf(tmp, 63, "worker.%i", n);
+ }
+
+ r = mkdir(tmp, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
+ if ( r ) {
+ ERROR("Failed to create temporary folder: %s\n",
+ strerror(errno));
+ return 1;
+ }
+
+ r = chdir(tmp);
+ if ( r ) {
+ ERROR("Failed to chdir to temporary folder: %s\n",
+ strerror(errno));
+ return 1;
+ }
+
+ return 0;
+}
+
+
static void start_worker_process(struct sandbox *sb, int slot,
int argc, char *argv[])
{
@@ -620,6 +654,8 @@ static void start_worker_process(struct sandbox *sb, int slot,
return;
}
+ create_temporary_folder(slot);
+
/* Free resources which will not be needed by worker */
for ( j=0; j<sb->n_proc; j++ ) {
if ( (j != slot) && (sb->running[j]) ) {
@@ -841,6 +877,8 @@ void create_sandbox(struct index_args *iargs, int n_proc, char *prefix,
return;
}
+ if ( create_temporary_folder(-1) ) return;
+
/* Fork the right number of times */
lock_sandbox(sb);
for ( i=0; i<n_proc; i++ ) {