version 1.12, 2006/02/20 08:38:18 |
version 1.13, 2006/05/10 14:32:51 |
|
|
execlp(editor, editor, filename, (void *)NULL); |
execlp(editor, editor, filename, (void *)NULL); |
warn("could not execute editor: %s", editor); |
warn("could not execute editor: %s", editor); |
cleanup(filename); |
cleanup(filename); |
/* NOTREACHED */ |
|
case -1: |
case -1: |
warn("could not fork"); |
warn("could not fork"); |
cleanup(filename); |
cleanup(filename); |
/* NOTREACHED */ |
|
} |
} |
|
|
/* parent */ |
/* parent */ |
|
|
if (waitpid(pid, &status, 0) == -1) { |
if (waitpid(pid, &status, 0) == -1) { |
warn("waitpid"); |
warn("waitpid"); |
cleanup(filename); |
cleanup(filename); |
/* NOTREACHED */ |
|
} |
} |
|
|
/* Check that editor terminated normally. */ |
/* Check that editor terminated normally. */ |
if (!WIFEXITED(status)) { |
if (!WIFEXITED(status)) { |
warn("%s terminated abnormally", editor); |
warn("%s terminated abnormally", editor); |
cleanup(filename); |
cleanup(filename); |
/* NOTREACHED */ |
|
} |
} |
} |
} |
|
|
|
|
if (!(file = fopen(filename, "r"))) { |
if (!(file = fopen(filename, "r"))) { |
warn("could not open edited file: %s", filename); |
warn("could not open edited file: %s", filename); |
cleanup(filename); |
cleanup(filename); |
/* NOTREACHED */ |
|
} |
} |
|
|
/* Copy temporary file contents to output file. */ |
/* Copy temporary file contents to output file. */ |
|
|
(ferror(file) || !feof(file))) { |
(ferror(file) || !feof(file))) { |
warnx("error reading edited file: %s", filename); |
warnx("error reading edited file: %s", filename); |
cleanup(filename); |
cleanup(filename); |
/* NOTREACHED */ |
|
} |
} |
|
|
/* |
/* |
|
|
if (nwritten != nread) { |
if (nwritten != nread) { |
warnx("error writing to output file"); |
warnx("error writing to output file"); |
cleanup(filename); |
cleanup(filename); |
/* NOTREACHED */ |
|
} |
} |
} |
} |
|
|