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

[BUG] Opening a unix fifo in "write" mode raises an exception #3208

Open
diocletiann opened this issue Jul 9, 2024 · 4 comments
Open

[BUG] Opening a unix fifo in "write" mode raises an exception #3208

diocletiann opened this issue Jul 9, 2024 · 4 comments
Labels
bug Something isn't working mojo-repo Tag all issues with this label

Comments

@diocletiann
Copy link

diocletiann commented Jul 9, 2024

Bug description

I'm not sure why this is failing, mentioned it on Discord and was asked to open an issue:

$ mojo run src/main.mojo
Unhandled exception caught during execution: unable to remove existing file /tmp/mojo.fifo
mojo: error: execution exited with a non-zero result: 1

This is the pipe:

$ ll /tmp/mojo.fifo
prwxrwxrwx  1 user  wheel     0B Jul  9 14:12 /tmp/mojo.fifo|

Steps to reproduce

$ mkfifo -m 777 /tmp/mojo.fifo
fn main() raises:
    var handle = open("/tmp/mojo.fifo", "w")

System information

MacOS 14.3.1
mojo 2024.7.905 (e860c551)
modular 0.8.0 (39a426b5)
@diocletiann diocletiann added bug Something isn't working mojo-repo Tag all issues with this label labels Jul 9, 2024
@diocletiann diocletiann changed the title [BUG] Opening a unix fifo in "write" mode throws an exception [BUG] Opening a unix fifo in "write" mode raises an exception Jul 9, 2024
Copy link
Collaborator

Looks like we're attempting to clear the the file before writing. This reproduces if the file is in a location that's owned by root but doesn't reproduce if the file is in a location owned by the user.

@diocletiann
Copy link
Author

diocletiann commented Jul 11, 2024

Looks like we're attempting to clear the the file before writing. This reproduces if the file is in a location that's owned by root but doesn't reproduce if the file is in a location owned by the user.

Well even in a location owned by the user, I tried open() with a text file and it deleted the file before it could even be read.

Copy link
Collaborator

ematejska commented Jul 11, 2024

Does that happen when you open it for reading with "r". I would expect that to happen when it's open for writing because the file is cleared out before writing happens….I believe that's how it works in Python as well.

@diocletiann
Copy link
Author

diocletiann commented Jul 11, 2024

"r" opens the file without data loss, sounds like an "rw" option is needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mojo-repo Tag all issues with this label
Projects
None yet
Development

No branches or pull requests

2 participants