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

Consider O_CLOEXEC when opening FIFOs? #339

Open
fandahao17 opened this issue Apr 19, 2020 · 3 comments
Open

Consider O_CLOEXEC when opening FIFOs? #339

fandahao17 opened this issue Apr 19, 2020 · 3 comments

Comments

@fandahao17
Copy link

Hi there! Thanks for your awesome project!

This is how I run into this problem: In main(), I started notification on FIFO /dev/pigpio0 and forked another process which runs pig2vcd to output the captured waveform. But I found that in the child process, I can't close /dev/pigpio0 even if I called gpioNotifyClose.

After going through the source code I found that by default, the actual close is done in the alert thread, but fork() only copies the main thread. I read the man page and found that this problem can be fixed by including O_CLOEXEC when calling open(). Will you consider adding this flag when opening FIFOs?

@guymcswain
Copy link
Collaborator

As an alternative approach, you could use pigpiod_if2 to open notifications via the socket then fork pig2vcd from there.

@joan2937
Copy link
Owner

I don't have any problem with the use of this flag. Mind you I have only had a quick skim through the man pages.

@guymcswain guymcswain mentioned this issue Apr 30, 2020
@guymcswain
Copy link
Collaborator

@fandahao17 , if you have a working proposal with test cases, please submit a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants