8 #define SPAWN_BUFSIZE 128
10 gboolean spawn_sync(char **argv,char **standard_output,int *exit_status,
13 /* Don't use g_spawn_sync on WIN32 for now to avoid needing the helper */
15 char *standard_error=NULL;
17 GSpawnFlags flags=G_SPAWN_SEARCH_PATH;
19 flags=G_SPAWN_STDOUT_TO_DEV_NULL;
20 retval=g_spawn_sync(NULL,argv,NULL,flags,NULL,NULL,standard_output,
21 &standard_error,exit_status,error);
23 fputs(standard_error,stderr);
24 g_free(standard_error);
25 if (retval && exit_status)
26 *exit_status=WEXITSTATUS(*exit_status);
32 GString *command_line,*string;
33 command_line=g_string_new(NULL);
37 g_string_append_c(command_line,' ');
38 g_string_append(command_line,argv[i]);
40 fp=popen(command_line->str,"r");
41 g_string_free(command_line,TRUE);
44 g_set_error(error,G_FILE_ERROR,g_file_error_from_errno(errno),
45 "%s: %s",command_line->str,g_strerror(errno));
48 string=g_string_new(NULL);
52 g_string_set_size(string,len+SPAWN_BUFSIZE);
53 n=fread(string->str+len,1,SPAWN_BUFSIZE,fp);
56 g_set_error(error,G_FILE_ERROR,g_file_error_from_errno(errno),
57 "Error reading from bookloupe: %s",g_strerror(errno));
59 g_string_free(string,TRUE);
62 g_string_set_size(string,len+n);
67 g_set_error(error,G_FILE_ERROR,g_file_error_from_errno(errno),
68 "Error reading from bookloupe: %s",g_strerror(errno));
69 g_string_free(string,TRUE);
77 *standard_output=g_string_free(string,FALSE);
79 g_string_free(string,TRUE);