- (implemented by forking "pwd" and reading its output) doesn't
- work when there are other child processes. Also, on all systems
- that implement getcwd that way "pwd" can't be found after chroot. */
- push_dir(NULL,0);
-
- if (write_batch && !am_server) {
- write_batch_argvs_file(orig_argc, orig_argv);
+ * (implemented by forking "pwd" and reading its output) doesn't
+ * work when there are other child processes. Also, on all systems
+ * that implement getcwd that way "pwd" can't be found after chroot. */
+ push_dir(NULL);
+
+ init_flist();
+
+ if (write_batch || read_batch) {
+ if (write_batch)
+ write_batch_shell_file(orig_argc, orig_argv, argc);
+
+ if (read_batch && strcmp(batch_name, "-") == 0)
+ batch_fd = STDIN_FILENO;
+ else {
+ batch_fd = do_open(batch_name,
+ write_batch ? O_WRONLY | O_CREAT | O_TRUNC
+ : O_RDONLY, S_IRUSR | S_IWUSR);
+ }
+ if (batch_fd < 0) {
+ rsyserr(FERROR, errno, "Batch file %s open error",
+ batch_name);
+ exit_cleanup(RERR_FILEIO);
+ }
+ if (read_batch)
+ read_stream_flags(batch_fd);