Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close every fd on detaching #1009

Closed
michaelrsweet opened this issue Nov 22, 2004 · 2 comments
Closed

Close every fd on detaching #1009

michaelrsweet opened this issue Nov 22, 2004 · 2 comments
Labels
enhancement New feature or request
Milestone

Comments

@michaelrsweet
Copy link
Collaborator

Version: 1.2-feature
CUPS.org User: kssingvo.suse

We noticed a bug in a different program (= not cupsd), where fds (= sockets) became not closed, before exec'ing cupsd. So the problem was that cupsd kept those fds open till he died. This was not good, because restarting the other application caused errors that it could not grap a special port.

So I'm asking for the following change: in file cups/scheduler/main.c

old:
if (fg < 1)
{
[...]
close(0);
close(1);
close(2);

new:
if (fg < 1)
{
int i;
int maxfd = getdtablesize();
[...]
for (i = 0; i < maxfd; i++)
close(fd);

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

Sounds harmless enough; will look into adding this to CUPS 1.2.

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

Fixed in Subversion repository.

Instead of using getdtablesize(), I used the current FD limit from getrlimit() which is more portable.

@michaelrsweet michaelrsweet added the enhancement New feature or request label Mar 17, 2016
@michaelrsweet michaelrsweet added this to the Stable milestone Mar 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant