- 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.
- */
-
- 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;
- }
- remove(tempEdit);
- fclose(obuf);
- fclose(newi);
- obuf = fbuf;
- goto out;
-fix:
- perror(tempEdit);
-out:
-# ifdef VMUNIX
- sigset(SIGCONT, scont);
-# endif VMUNIX
- sigset(SIGINT, sig);
- newi = ibuf;
- return(obuf);
+ (void) signal(SIGINT, sigint);
+ (void) signal(SIGCONT, sigcont);