-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
nodejs process cannot exit if opened a named pipe with no one reading #3628
Comments
That wouldn't help with FIFOs on most platforms. Opening a FIFO for writing in non-blocking mode is undefined according to POSIX. It works on Linux but fails with ENXIO on OS X, for example. If you're targeting Linux, you can set up non-blocking mode manually: const C = require('constants');
const fs = require('fs');
const net = require('net');
const fd = fs.openSync('/path/to/fifo', C.O_NONBLOCK | C.O_RDWR);
const socket = new net.Socket({ fd, readable: true, writable: true }); |
@bnoordhuis can I take |
Btw this is from Linux
And results of your code on Linux:
It also fails with ENXIO. --- EDIT --- |
There is no separate API documentation if that is what you mean but you can find references to it in the documentation for other core modules.
Sorry, I meant to say "for reading or writing", not just "for writing". At any rate, you see now why node works the way it does. |
Yes, opening a FIFO with O_RDWR is undefined, but it is well defined for both O_RDONLY and O_WRONLY, either with or without O_NONBLOCK. So the UB on opening FIFO with O_RDWR does not at all relate to opening files with O_NONBLOCK, and of course I would prefer non-blocking --- why shall I bother with (infinite) blocking when using the async API? As for documentation, the But I agree that changing the default bahavior would be breaking, so can we either implement more flags or document this case and its workaround? |
Yes. It goes all the way back to node v0.1.x.
"Silly" is subjective. "Never block" is misleading - Changing
What flags are you referring to? It's ambiguous from context.
Documentation pull requests are welcome with the caveat that the reference documentation shouldn't turn into a collection of UNIX trivia. That is, keep it short and succinct. |
More flags in addition to "r", "r+", "w", ...
Can I assume that we do and will continue to support numeric flags to fs.open on UNIX? |
You can try a pull request but I don't know how much traction you'll get.
Yes. It's been there since the very beginning, it's works, it's not broken, people use it. In short, there is no reason to remove it. |
I am assuming that this issue can be closed now that the PR landed. |
There is a thread blocked in
pipe_wait
, as shown in itswchan
.Can we always open the file in non-blocking mode? After all it has no effect for real disk files, but avoids infinite waiting when that happens to be a named pipe.
The text was updated successfully, but these errors were encountered: