The purpose of O_NOCTTY is documented as :
O_NOCTTY - prevent the OS from assigning the opened file as the process's controlling terminal when opening a TTY device file
Can somebody explain the intention of preventing a file as opening a controlling terminal ?
Having a controlling tty means there are certain conditions where specific signals might be sent to your program in response to things happening on the tty/window where your program is running. If the program is intended to be a daemon, it's generally cleaner to make sure you don't have a controlling tty than it is to try to write code to handle all the extra conditions that you don't really care about to begin with...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With