Browse Source

Handle system errors when launching editor

tags/fmail-0.1.1
Damien Goutte-Gattat 9 years ago
parent
commit
5ba0a7ed89
1 changed files with 10 additions and 4 deletions
  1. +10
    -4
      src/fmail.c

+ 10
- 4
src/fmail.c View File

@@ -434,13 +434,19 @@ read_input_from_editor(void)
FILE *f;

editor = get_editor();
command = xmalloc(strlen(editor) + sizeof(tmp_filename) + 1);

tmp_fd = mkstemp(tmp_filename);
if ( (tmp_fd = mkstemp(tmp_filename)) == -1 )
err(EXIT_FAILURE, "cannot create temporary file");

command = xmalloc(strlen(editor) + sizeof(tmp_filename) + 1);
sprintf(command, "%s %s", editor, tmp_filename);
system(command);

f = fdopen(tmp_fd, "r");
if ( system(command) == -1 )
err(EXIT_FAILURE, "cannot execute editor '%s'", editor);

if ( (f = fdopen(tmp_fd, "r")) == NULL )
err(EXIT_FAILURE, "cannot open temporary file");

unlink(tmp_filename);
free(command);



Loading…
Cancel
Save