diff -r faab25d520dd -r 721e468c10f3 bl/spawn.c --- a/bl/spawn.c Fri Jan 27 16:18:02 2012 +0000 +++ b/bl/spawn.c Fri Jan 27 21:40:35 2012 +0000 @@ -7,26 +7,22 @@ #define SPAWN_BUFSIZE 128 -gboolean spawn_sync(char **argv,char **standard_output,int *exit_status) +gboolean spawn_sync(char **argv,char **standard_output,int *exit_status, + GError **error) { /* Don't use g_spawn_sync on WIN32 for now to avoid needing the helper */ #ifndef WIN32 - char *standard_error; - GError *error=NULL; + char *standard_error=NULL; gboolean retval; GSpawnFlags flags=G_SPAWN_SEARCH_PATH; if (!standard_output) flags=G_SPAWN_STDOUT_TO_DEV_NULL; retval=g_spawn_sync(NULL,argv,NULL,flags,NULL,NULL,standard_output, - &standard_error,exit_status,&error); - fputs(standard_error,stderr); + &standard_error,exit_status,error); + if (standard_error) + fputs(standard_error,stderr); g_free(standard_error); - if (!retval) - { - fprintf(stderr,"%s\n",error->message); - g_error_free(error); - } - else if (exit_status) + if (retval && exit_status) *exit_status=WEXITSTATUS(*exit_status); return retval; #else @@ -45,7 +41,8 @@ g_string_free(command_line,TRUE); if (!fp) { - perror(command_line->str); + g_set_error(error,G_FILE_ERROR,g_file_error_from_errno(errno), + "%s: %s",command_line->str,g_strerror(errno)); return FALSE; } string=g_string_new(NULL); @@ -56,7 +53,8 @@ n=fread(string->str+len,1,SPAWN_BUFSIZE,fp); if (n<0) { - perror("fread"); + g_set_error(error,G_FILE_ERROR,g_file_error_from_errno(errno), + "Error reading from bookloupe: %s",g_strerror(errno)); (void)pclose(fp); g_string_free(string,TRUE); return FALSE; @@ -66,7 +64,8 @@ r=pclose(fp); if (r<0) { - perror("pclose"); + g_set_error(error,G_FILE_ERROR,g_file_error_from_errno(errno), + "Error reading from bookloupe: %s",g_strerror(errno)); g_string_free(string,TRUE); return FALSE; }