- sigint = signal(SIGINT, SIG_IGN);
- sigcont = signal(SIGCONT, SIG_DFL);
- 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;
- }
- while ((t = getc(fp)) != EOF)
- putc(t, fbuf);
- 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 (sigint != SIG_IGN)
- signal(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.w_status != 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;