+ if (pipe(property_pipe) < 0) {
+ err = vstrallocf(_("pipe failed: %s"), strerror(errno));
+ goto common_exit;
+ }
+ fflush(stdout);fflush(stderr);
+
+ switch (backup_api_pid = fork()) {
+ case -1:
+ err = vstrallocf(_("fork failed: %s"), strerror(errno));
+ goto common_exit;
+
+ case 0: /* child */
+ {
+ char *argvchild[14];
+ char *cmd = vstralloc(DUMPER_DIR, "/", program, NULL);
+ int j=0;
+ argvchild[j++] = program;
+ argvchild[j++] = "selfcheck";
+ if (bsu->message_line == 1) {
+ argvchild[j++] = "--message";
+ argvchild[j++] = "line";
+ }
+ if (g_options->config != NULL && bsu->config == 1) {
+ argvchild[j++] = "--config";
+ argvchild[j++] = g_options->config;
+ }
+ if (g_options->hostname != NULL && bsu->host == 1) {
+ argvchild[j++] = "--host";
+ argvchild[j++] = g_options->hostname;
+ }
+ if (disk != NULL && bsu->disk == 1) {
+ argvchild[j++] = "--disk";
+ argvchild[j++] = disk;
+ }
+ argvchild[j++] = "--device";
+ argvchild[j++] = amdevice;
+ if(options && options->createindex && bsu->index_line == 1) {
+ argvchild[j++] = "--index";
+ argvchild[j++] = "line";
+ }
+ if (!options->no_record && bsu->record == 1) {
+ argvchild[j++] = "--record";
+ }
+ argvchild[j++] = NULL;
+ dup2(property_pipe[0], 0);
+ aclose(property_pipe[1]);
+ safe_fd(-1, 0);
+ execve(cmd,argvchild,safe_env());
+ g_printf(_("ERROR [Can't execute %s: %s]\n"), cmd, strerror(errno));
+ exit(127);
+ }
+ default: /* parent */
+ {
+ int status;
+ aclose(property_pipe[0]);
+ toolin = fdopen(property_pipe[1],"w");
+ if (!toolin) {
+ err = vstrallocf(_("Can't fdopen: %s"), strerror(errno));
+ goto common_exit;
+ }
+ output_tool_property(toolin, options);
+ fflush(toolin);
+ fclose(toolin);
+ if (waitpid(backup_api_pid, &status, 0) < 0) {
+ if (!WIFEXITED(status)) {
+ err = vstrallocf(_("Tool exited with signal %d"),
+ WTERMSIG(status));
+ } else if (WEXITSTATUS(status) != 0) {
+ err = vstrallocf(_("Tool exited with status %d"),
+ WEXITSTATUS(status));
+ } else {
+ err = vstrallocf(_("waitpid returned negative value"));
+ }
+ goto common_exit;
+ }
+ }
+ }
+ amfree(bsu);
+ fflush(stdout);fflush(stderr);
+ amfree(device);
+ amfree(qamdevice);
+ amfree(qdisk);
+ return;
+ }
+
+ qdevice = quote_string(device);
+ dbprintf(_("device %s\n"), qdevice);