+ case 0: /* child */
+ {
+ GPtrArray *argv_ptr = g_ptr_array_new();
+ guint i;
+ char *cmd = vstralloc(APPLICATION_DIR, "/", dle->program, NULL);
+ GSList *scriptlist;
+ script_t *script;
+ estimatelist_t el;
+ char *cmdline;
+
+ aclose(app_err[0]);
+ dup2(app_err[1], 2);
+
+ g_ptr_array_add(argv_ptr, stralloc(dle->program));
+ g_ptr_array_add(argv_ptr, stralloc("selfcheck"));
+ if (bsu->message_line == 1) {
+ g_ptr_array_add(argv_ptr, stralloc("--message"));
+ g_ptr_array_add(argv_ptr, stralloc("line"));
+ }
+ if (g_options->config != NULL && bsu->config == 1) {
+ g_ptr_array_add(argv_ptr, stralloc("--config"));
+ g_ptr_array_add(argv_ptr, stralloc(g_options->config));
+ }
+ if (g_options->hostname != NULL && bsu->host == 1) {
+ g_ptr_array_add(argv_ptr, stralloc("--host"));
+ g_ptr_array_add(argv_ptr, stralloc(g_options->hostname));
+ }
+ if (dle->disk != NULL && bsu->disk == 1) {
+ g_ptr_array_add(argv_ptr, stralloc("--disk"));
+ g_ptr_array_add(argv_ptr, stralloc(dle->disk));
+ }
+ if (dle->device) {
+ g_ptr_array_add(argv_ptr, stralloc("--device"));
+ g_ptr_array_add(argv_ptr, stralloc(dle->device));
+ }
+ if (dle->create_index && bsu->index_line == 1) {
+ g_ptr_array_add(argv_ptr, stralloc("--index"));
+ g_ptr_array_add(argv_ptr, stralloc("line"));
+ }
+ if (dle->record && bsu->record == 1) {
+ g_ptr_array_add(argv_ptr, stralloc("--record"));
+ }
+
+ for (el = dle->estimatelist; el != NULL; el=el->next) {
+ estimate_t estimate = (estimate_t)GPOINTER_TO_INT(el->data);
+ if (estimate == ES_CALCSIZE && bsu->calcsize == 1) {
+ g_ptr_array_add(argv_ptr, stralloc("--calcsize"));
+ }
+ }
+ application_property_add_to_argv(argv_ptr, dle, bsu,
+ g_options->features);
+
+ for (scriptlist = dle->scriptlist; scriptlist != NULL;
+ scriptlist = scriptlist->next) {
+ script = (script_t *)scriptlist->data;
+ if (script->result && script->result->proplist) {
+ property_add_to_argv(argv_ptr,
+ script->result->proplist);
+ }
+ }
+
+ g_ptr_array_add(argv_ptr, NULL);
+
+ cmdline = stralloc(cmd);
+ for (i = 0; i < argv_ptr->len-1; i++) {
+ char *quoted = quote_string(
+ (char *)g_ptr_array_index(argv_ptr,i));
+ cmdline = vstrextend(&cmdline, " ", quoted, NULL);
+ amfree(quoted);
+ }
+ dbprintf(_("Spawning \"%s\" in pipeline\n"), cmdline);
+ amfree(cmdline);
+
+ safe_fd(-1, 0);
+ execve(cmd, (char **)argv_ptr->pdata, safe_env());
+ g_printf(_("ERROR [Can't execute %s: %s]\n"), cmd, strerror(errno));
+ exit(127);
+ }
+ default: /* parent */
+ {
+ int status;
+ FILE *app_stderr;
+ char *line;
+
+ aclose(app_err[1]);
+ app_stderr = fdopen(app_err[0], "r");
+ while((line = agets(app_stderr)) != NULL) {
+ if (strlen(line) > 0) {
+ fprintf(stdout, "ERROR Application '%s': %s\n",
+ dle->program, line);
+ dbprintf("ERROR %s\n", line);
+ }
+ amfree(line);
+ }
+ fclose(app_stderr);
+ if (waitpid(application_api_pid, &status, 0) < 0) {
+ err = vstrallocf(_("waitpid failed: %s"),
+ strerror(errno));
+ goto common_exit;
+ } else if (!WIFEXITED(status)) {
+ err = vstrallocf(_("Application '%s': exited with signal %d"),
+ dle->program, WTERMSIG(status));
+ goto common_exit;
+ } else if (WEXITSTATUS(status) != 0) {
+ err = vstrallocf(_("Application '%s': exited with status %d"),
+ dle->program, WEXITSTATUS(status));
+ goto common_exit;
+ }
+ }
+ }
+ amfree(bsu);
+ fflush(stdout);fflush(stderr);
+ amfree(device);
+ amfree(qamdevice);
+ amfree(qdisk);
+ return;
+ }
+
+ if (device) {
+ qdevice = quote_string(device);
+ dbprintf(_("device %s\n"), qdevice);
+
+ /* skip accessability test if this is an AFS entry */
+ if(strncmp_const(device, "afs:") != 0) {