init: exit on failure to add all jobs
[fio.git] / init.c
diff --git a/init.c b/init.c
index c3cc3e54a38f514804a3b095c175f2a23e9b32ff..213844647752f4212f88e7dd837149defbf833b5 100644 (file)
--- a/init.c
+++ b/init.c
@@ -356,6 +356,9 @@ static int setup_thread_area(void)
                perror("shmat");
                return 1;
        }
+#ifdef FIO_HAVE_SHM_ATTACH_REMOVED
+       shmctl(shm_id, IPC_RMID, NULL);
+#endif
 #endif
 
        memset(threads, 0, max_jobs * sizeof(struct thread_data));
@@ -2323,17 +2326,22 @@ int parse_cmd_line(int argc, char *argv[], int client_type)
                case 'b':
                        write_bw_log = 1;
                        break;
-               case 'o':
+               case 'o': {
+                       FILE *tmp;
+
                        if (f_out && f_out != stdout)
                                fclose(f_out);
 
-                       f_out = fopen(optarg, "w+");
-                       if (!f_out) {
-                               perror("fopen output");
-                               exit(1);
+                       tmp = fopen(optarg, "w+");
+                       if (!tmp) {
+                               log_err("fio: output file open error: %s\n", strerror(errno));
+                               exit_val = 1;
+                               do_exit++;
+                               break;
                        }
-                       f_err = f_out;
+                       f_err = f_out = tmp;
                        break;
+                       }
                case 'm':
                        output_format = FIO_OUTPUT_TERSE;
                        break;
@@ -2705,7 +2713,7 @@ int parse_cmd_line(int argc, char *argv[], int client_type)
                if (!ret) {
                        ret = add_job(td, td->o.name ?: "fio", 0, 0, client_type);
                        if (ret)
-                               did_arg = 1;
+                               exit(1);
                }
        }