- pid = vfork();
- if (pid == -1) {
- perror("fork");
- remove(edname);
- goto out;
- }
- if (pid == 0) {
- if (sigint != SIG_IGN)
- signal(SIGINT, SIG_DFL);
- if (sigquit != SIG_IGN)
- signal(SIGQUIT, SIG_DFL);
- execl(ed, ed, edname, 0);
- perror(ed);
- _exit(1);
- }
- while (wait(&mesg) != pid)
- ;
-
- /*
- * Now copy the message to the end of the
- * temp file.
- */
-
- if (stat(edname, &statb) < 0) {
- perror(edname);
- goto out;
- }
- if (modtime == statb.st_mtime) {
- remove(edname);
- goto out;
- }
- if ((ibuf = fopen(edname, "r")) == NULL) {
- perror(edname);
- remove(edname);
- goto out;
- }
- remove(edname);
- fseek(otf, (long) 0, 2);
- size = fsize(otf);
- mp->m_block = blockof(size);
- mp->m_offset = offsetof(size);
- ms = 0;
- lines = 0;
- while ((c = getc(ibuf)) != EOF) {
- if (c == '\n')
- lines++;
- putc(c, otf);
- if (ferror(otf))
- break;
- ms++;
- }
- mp->m_size = ms;
- mp->m_lines = lines;
- if (ferror(otf))
- perror("/tmp");
- fclose(ibuf);
+ if (ferror(nf)) {
+ (void) Fclose(nf);
+ perror(tempEdit);
+ (void) unlink(tempEdit);
+ nf = NULL;
+ goto out;
+ }
+ if (Fclose(nf) < 0) {
+ perror(tempEdit);
+ (void) unlink(tempEdit);
+ nf = NULL;
+ goto out;
+ }
+ nf = NULL;
+ if ((edit = value(type == 'e' ? "EDITOR" : "VISUAL")) == NOSTR)
+ edit = type == 'e' ? _PATH_EX : _PATH_VI;
+ if (run_command(edit, 0, -1, -1, tempEdit, NOSTR, NOSTR) < 0) {
+ (void) unlink(tempEdit);
+ goto out;