- sig = sigset(SIGINT, SIG_IGN);
- scont = sigset(SIGCONT, foonly);
- 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) {
- 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.
- */
-
- if ((fbuf = fopen(tempEdit, "a")) == NULL) {
- perror(tempEdit);
- remove(tempEdit);
- goto out;
- }
- if ((ibuf = fopen(tempEdit, "r")) == NULL) {
- perror(tempEdit);
- fclose(fbuf);
- remove(tempEdit);
- goto out;