aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2013-02-08 12:36:39 -0800
committerThomas White <taw@physics.org>2013-02-08 12:36:39 -0800
commitd8ff3bdfcc020ec296d2ad81209fce744343ad57 (patch)
treea660283cc4c4070bdfc2b55ec83bf8c093be684a
parentdac436f21df140b6bf0796f6f9cbb6fcb6c03e2d (diff)
Put the command line back in the stream
-rw-r--r--libcrystfel/src/stream.c18
-rw-r--r--libcrystfel/src/stream.h6
-rw-r--r--src/im-sandbox.c10
-rw-r--r--src/im-sandbox.h3
-rw-r--r--src/indexamajig.c2
5 files changed, 30 insertions, 9 deletions
diff --git a/libcrystfel/src/stream.c b/libcrystfel/src/stream.c
index 877a1824..a9e6a441 100644
--- a/libcrystfel/src/stream.c
+++ b/libcrystfel/src/stream.c
@@ -557,6 +557,24 @@ int is_stream(const char *filename)
}
+void write_line(Stream *st, const char *line)
+{
+ fprintf(st->fh, "%s\n", line);
+}
+
+
+void write_command(Stream *st, int argc, char *argv[])
+{
+ int i;
+
+ for ( i=0; i<argc; i++ ) {
+ if ( i > 0 ) fprintf(st->fh, " ");
+ fprintf(st->fh, "%s", argv[i]);
+ }
+ fprintf(st->fh, "\n");
+}
+
+
/**
* rewind_stream:
* @st: A %Stream
diff --git a/libcrystfel/src/stream.h b/libcrystfel/src/stream.h
index cdce0ea2..08e680bc 100644
--- a/libcrystfel/src/stream.h
+++ b/libcrystfel/src/stream.h
@@ -53,16 +53,16 @@ typedef struct _stream Stream;
extern Stream *open_stream_for_read(const char *filename);
extern Stream *open_stream_for_write(const char *filename);
extern Stream *open_stream_fd_for_write(int fd);
-
extern void close_stream(Stream *st);
+extern int read_chunk(Stream *st, struct image *image);
extern void write_chunk(Stream *st, struct image *image, struct hdfile *hdfile,
int include_peaks, int include_reflections);
-extern int read_chunk(Stream *st, struct image *image);
+extern void write_line(Stream *st, const char *line);
+extern void write_command(Stream *st, int argc, char *argv[]);
extern int rewind_stream(Stream *st);
-
extern int is_stream(const char *filename);
#endif /* STREAM_H */
diff --git a/src/im-sandbox.c b/src/im-sandbox.c
index 646b5002..f14d5a11 100644
--- a/src/im-sandbox.c
+++ b/src/im-sandbox.c
@@ -569,7 +569,8 @@ static void *run_reader(void *sbv)
}
-static void start_worker_process(struct sandbox *sb, int slot)
+static void start_worker_process(struct sandbox *sb, int slot,
+ int argc, char *argv[])
{
pid_t p;
int filename_pipe[2];
@@ -631,6 +632,7 @@ static void start_worker_process(struct sandbox *sb, int slot)
close(result_pipe[0]);
st = open_stream_fd_for_write(sb->stream_pipe_write[slot]);
+ write_command(st, argc, argv);
run_work(sb->iargs, filename_pipe[0], result_pipe[1],
st, slot);
close_stream(st);
@@ -701,7 +703,7 @@ static void handle_zombie(struct sandbox *sb)
STATUS("Last filename was: %s\n",
sb->last_filename[i]);
sb->n_processed++;
- start_worker_process(sb, i);
+ start_worker_process(sb, i, 0, NULL);
}
}
@@ -713,7 +715,7 @@ static void handle_zombie(struct sandbox *sb)
void create_sandbox(struct index_args *iargs, int n_proc, char *prefix,
int config_basename, FILE *fh, char *use_this_one_instead,
- FILE *ofh)
+ FILE *ofh, int argc, char *argv[])
{
int i;
int allDone;
@@ -823,7 +825,7 @@ void create_sandbox(struct index_args *iargs, int n_proc, char *prefix,
/* Fork the right number of times */
lock_sandbox(sb);
for ( i=0; i<n_proc; i++ ) {
- start_worker_process(sb, i);
+ start_worker_process(sb, i, argc, argv);
}
unlock_sandbox(sb);
diff --git a/src/im-sandbox.h b/src/im-sandbox.h
index 96311056..540312ed 100644
--- a/src/im-sandbox.h
+++ b/src/im-sandbox.h
@@ -76,4 +76,5 @@ struct index_args
extern void create_sandbox(struct index_args *iargs, int n_proc, char *prefix,
int config_basename, FILE *fh,
- char *use_this_one_instead, FILE *stream);
+ char *use_this_one_instead, FILE *stream,
+ int argc, char *argv[]);
diff --git a/src/indexamajig.c b/src/indexamajig.c
index 8b0f5206..d36b2811 100644
--- a/src/indexamajig.c
+++ b/src/indexamajig.c
@@ -595,7 +595,7 @@ int main(int argc, char *argv[])
iargs.include_reflections = 1; /* FIXME! */
create_sandbox(&iargs, n_proc, prefix, config_basename, fh,
- use_this_one_instead, ofh);
+ use_this_one_instead, ofh, argc, argv);
free(prefix);