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

Should we monitor/link to the controlling_process? #125

Open
ewildgoose opened this issue Mar 10, 2022 · 1 comment
Open

Should we monitor/link to the controlling_process? #125

ewildgoose opened this issue Mar 10, 2022 · 1 comment

Comments

@ewildgoose
Copy link

At present the library links when started with start_link (which is expected). However, consider that we start the library under a supervisor, and then some other genserver calls controlling_process and open, etc. If this process exits it seems desirable (to me) to close the serial port?

Now I can trap exits in the genserver process, but that leads to a rabbit hole of how tricky that is to get right, and the main alternative would be for the genserver to link to the circuits_uart process. However, I can't quite decide if that's a good idea or not? It has implications good and bad about what happens if the genserver process crashes during a message transmission over the serial port? However, the counter point is that closing the serial port also has some similar implications (although I guess we can choose to guard these by draining sending buffers on termination, etc?)

I'm genuinely not sure what is the right answer, but I notice that we are modelling this after gen_tcp and the like, and those will monitor (and link) to the process passed in controlling_process. Should the same logic be used here? (Possibly then with some concerns about whether to drain transmit buffers on close?)

@fhunleth
Copy link
Contributor

Hi @ewildgoose - thanks for posting about this!

it's been a while since I've actively maintained circuits_uart. I think that if I were to revisit that I'd change a couple things and the supervision structure definitely sounds like it needs more thought. I think that you're right about closing the serial port and at least doing a best effort attempt at flushing transmit buffers.

If you want to start a PR, I'll try to allocate some time for the library.

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

2 participants