SCCS-vsn: sys/kern/kern_descrip.c 7.5
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#)kern_descrip.c 7.4 (Berkeley) %G%
+ * @(#)kern_descrip.c 7.5 (Berkeley) %G%
int i, j;
} *uap = (struct a *) u.u_ap;
register struct file *fp;
int i, j;
} *uap = (struct a *) u.u_ap;
register struct file *fp;
if ((unsigned)uap->i >= NOFILE || (fp = u.u_ofile[uap->i]) == NULL)
RETURN (EBADF);
if ((unsigned)uap->i >= NOFILE || (fp = u.u_ofile[uap->i]) == NULL)
RETURN (EBADF);
- if (uap->j < 0 || uap->j >= NOFILE) {
- u.u_error = EBADF;
- return;
- }
+ if (uap->j < 0 || uap->j >= NOFILE)
+ RETURN (EBADF);
u.u_r.r_val1 = uap->j;
if (uap->i == uap->j)
u.u_r.r_val1 = uap->j;
if (uap->i == uap->j)
if (u.u_ofile[uap->j]) {
if (u.u_pofile[uap->j] & UF_MAPPED)
munmapfd(uap->j);
if (u.u_ofile[uap->j]) {
if (u.u_pofile[uap->j] & UF_MAPPED)
munmapfd(uap->j);
- closef(u.u_ofile[uap->j]);
- if (u.u_error)
- return;
+ error = closef(u.u_ofile[uap->j]);
}
dupit(uap->j, fp, u.u_pofile[uap->i] &~ UF_EXCLOSE);
}
dupit(uap->j, fp, u.u_pofile[uap->i] &~ UF_EXCLOSE);
+ /*
+ * dup2() must succeed even though the close had an error.
+ */
+ error = 0; /* XXX */
+ RETURN (error);
while (u.u_lastfile >= 0 && u.u_ofile[u.u_lastfile] == NULL)
u.u_lastfile--;
*pf = 0;
while (u.u_lastfile >= 0 && u.u_ofile[u.u_lastfile] == NULL)
u.u_lastfile--;
*pf = 0;
- closef(fp);
- /* WHAT IF u.u_error ? */
closef(fp)
register struct file *fp;
{
closef(fp)
register struct file *fp;
{
if (fp->f_count > 1) {
fp->f_count--;
if (fp->f_count > 1) {
fp->f_count--;
}
if (fp->f_count < 1)
panic("closef: count < 1");
}
if (fp->f_count < 1)
panic("closef: count < 1");
- (*fp->f_ops->fo_close)(fp);
+ error = (*fp->f_ops->fo_close)(fp);
crfree(fp->f_cred);
fp->f_count = 0;
crfree(fp->f_cred);
fp->f_count = 0;