Home | History | Annotate | Download | only in import

Lines Matching refs:newfd

149 /* Mark NEWFD as a duplicate of OLDFD; useful from dup, dup2, dup3,
151 descriptors. Close NEWFD and return -1 if OLDFD is tracking a
153 directory in NEWFD; otherwise return NEWFD. */
155 _gl_register_dup (int oldfd, int newfd)
157 assure (0 <= oldfd && 0 <= newfd && oldfd != newfd);
160 /* Duplicated a directory; must ensure newfd is allocated. */
161 if (!ensure_dirs_slot (newfd)
162 || (dirs[newfd].name = strdup (dirs[oldfd].name)) == NULL)
165 close (newfd);
167 newfd = -1;
170 else if (newfd < dirs_allocated)
172 /* Duplicated a non-directory; ensure newfd is cleared. */
173 free (dirs[newfd].name);
174 dirs[newfd].name = NULL;
176 return newfd;