Remove dead code which supported systems without O_APPEND, O_CREAT or SIGTSTP.
This commit is contained in:
parent
1d25e6987d
commit
8435c561b3
@ -189,37 +189,16 @@ openredirect(union node *redir, char memory[10])
|
||||
break;
|
||||
case NFROMTO:
|
||||
fname = redir->nfile.expfname;
|
||||
#ifdef O_CREAT
|
||||
if ((f = open(fname, O_RDWR|O_CREAT, 0666)) < 0)
|
||||
error("cannot create %s: %s", fname, strerror(errno));
|
||||
#else
|
||||
if ((f = open(fname, O_RDWR, 0666)) < 0) {
|
||||
if (errno != ENOENT)
|
||||
error("cannot create %s: %s", fname, strerror(errno));
|
||||
else if ((f = creat(fname, 0666)) < 0)
|
||||
error("cannot create %s: %s", fname, strerror(errno));
|
||||
else {
|
||||
close(f);
|
||||
if ((f = open(fname, O_RDWR)) < 0) {
|
||||
error("cannot create %s: %s", fname, strerror(errno));
|
||||
remove(fname);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
goto movefd;
|
||||
case NTO:
|
||||
fname = redir->nfile.expfname;
|
||||
if (Cflag && stat(fname, &sb) != -1 && S_ISREG(sb.st_mode))
|
||||
error("cannot create %s: %s", fname,
|
||||
strerror(EEXIST));
|
||||
#ifdef O_CREAT
|
||||
if ((f = open(fname, O_WRONLY|O_CREAT|O_TRUNC, 0666)) < 0)
|
||||
error("cannot create %s: %s", fname, strerror(errno));
|
||||
#else
|
||||
if ((f = creat(fname, 0666)) < 0)
|
||||
error("cannot create %s: %s", fname, strerror(errno));
|
||||
#endif
|
||||
goto movefd;
|
||||
case NCLOBBER:
|
||||
fname = redir->nfile.expfname;
|
||||
@ -228,15 +207,8 @@ openredirect(union node *redir, char memory[10])
|
||||
goto movefd;
|
||||
case NAPPEND:
|
||||
fname = redir->nfile.expfname;
|
||||
#ifdef O_APPEND
|
||||
if ((f = open(fname, O_WRONLY|O_CREAT|O_APPEND, 0666)) < 0)
|
||||
error("cannot create %s: %s", fname, strerror(errno));
|
||||
#else
|
||||
if ((f = open(fname, O_WRONLY)) < 0
|
||||
&& (f = creat(fname, 0666)) < 0)
|
||||
error("cannot create %s: %s", fname, strerror(errno));
|
||||
lseek(f, (off_t)0, 2);
|
||||
#endif
|
||||
goto movefd;
|
||||
case NTOFD:
|
||||
case NFROMFD:
|
||||
@ -287,9 +259,7 @@ openhere(union node *redir)
|
||||
signal(SIGINT, SIG_IGN);
|
||||
signal(SIGQUIT, SIG_IGN);
|
||||
signal(SIGHUP, SIG_IGN);
|
||||
#ifdef SIGTSTP
|
||||
signal(SIGTSTP, SIG_IGN);
|
||||
#endif
|
||||
signal(SIGPIPE, SIG_DFL);
|
||||
if (redir->type == NHERE)
|
||||
xwrite(pip[1], redir->nhere.doc->narg.text, len);
|
||||
|
@ -374,9 +374,7 @@ opentrace(void)
|
||||
{
|
||||
char s[100];
|
||||
char *getenv();
|
||||
#ifdef O_APPEND
|
||||
int flags;
|
||||
#endif
|
||||
|
||||
if (!debug)
|
||||
return;
|
||||
@ -399,10 +397,8 @@ opentrace(void)
|
||||
fprintf(stderr, "Can't open %s: %s\n", s, strerror(errno));
|
||||
return;
|
||||
}
|
||||
#ifdef O_APPEND
|
||||
if ((flags = fcntl(fileno(tracefile), F_GETFL, 0)) >= 0)
|
||||
fcntl(fileno(tracefile), F_SETFL, flags | O_APPEND);
|
||||
#endif
|
||||
fputs("\nTracing started.\n", tracefile);
|
||||
fflush(tracefile);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user