Skip to content

Commit

Permalink
Improve style of sh_close()
Browse files Browse the repository at this point in the history
Looking into issue #1438 caused me to notice the style of `sh_close()`
would benefit from some tweaking.
  • Loading branch information
krader1961 committed Nov 15, 2019
1 parent d72c3a6 commit c99e9ff
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/cmd/ksh93/sh/io.c
Expand Up @@ -455,21 +455,20 @@ int sh_iorenumber(Shell_t *shp, int f1, int f2) {
//
int sh_close(int fd) {
Shell_t *shp = sh_getinterp();
Sfio_t *sp;
int r = 0;

if (!sh_iovalidfd(shp, fd)) {
errno = EBADF;
return -1;
}

if (!(sp = shp->sftable[fd]) || (sffileno(sp) != fd) || (sfclose(sp) < 0)) {
Sfio_t *sp = shp->sftable[fd];
if (!sp || sffileno(sp) != fd || sfclose(sp) < 0) {
if (fdnotify) (*fdnotify)(fd, SH_FDCLOSE);
close(fd);
}

if (fd > 2) shp->sftable[fd] = 0;
r = (shp->fdstatus[fd] >> 8);
if (fd > STDERR_FILENO) shp->sftable[fd] = 0;
int r = (shp->fdstatus[fd] >> 8);
if (r) close(r);
shp->fdstatus[fd] = IOCLOSE;
if (shp->fdptrs[fd]) *shp->fdptrs[fd] = -1;
Expand Down

0 comments on commit c99e9ff

Please sign in to comment.