- int pid, s;
- FILE *fbuf;
- register int t;
- int (*sig)(), (*scont)(), signull();
- struct stat sbuf;
- extern char tempMail[], tempEdit[];
- register char *edit;
-
- sig = sigset(SIGINT, SIG_IGN);
-# ifdef VMUNIX
- scont = sigset(SIGCONT, signull);
-# endif VMUNIX
- if (stat(tempEdit, &sbuf) >= 0) {
- printf("%s: file exists\n", tempEdit);
- goto out;
- }
- close(creat(tempEdit, 0600));
- if ((fbuf = fopen(tempEdit, "w")) == NULL) {
- perror(tempEdit);
- goto out;
- }
- fflush(obuf);
- rewind(ibuf);
- t = getc(ibuf);
- while (t != EOF) {
- putc(t, fbuf);
- t = getc(ibuf);
- }
- fflush(fbuf);
- if (ferror(fbuf)) {
- perror(tempEdit);
- remove(tempEdit);
- goto fix;
- }
- fclose(fbuf);
- if ((edit = value(c == 'e' ? "EDITOR" : "VISUAL")) == NOSTR)
- edit = c == 'e' ? EDITOR : VISUAL;
- pid = vfork();
- if (pid == 0) {
- sigchild();
- if (sig != SIG_IGN)
- sigsys(SIGINT, SIG_DFL);
- execl(edit, edit, tempEdit, 0);
- perror(edit);
- _exit(1);
- }
- if (pid == -1) {
- perror("fork");
- remove(tempEdit);
- goto out;
- }
- while (wait(&s) != pid)
- ;
- if ((s & 0377) != 0) {
- printf("Fatal error in \"%s\"\n", edit);
- remove(tempEdit);
- goto out;
- }
-
- /*
- * Now switch to new file.
- */
+ sig_t sigint = signal(SIGINT, SIG_IGN);
+ FILE *nf = run_editor(fp, (off_t)-1, c, 0);