Everyone says that daemon should not have a controlling terminal. And double-fork method is the correct way that a double-forked daemon will never acquire a controlling terminal since it's not a session leader.
However, if we create a single fork daemon with using setsid(), close all fds, redirect fd 0~2 to /dev/null, but still the daemon is a session leader.
Then how can it reacquire a controlling terminal? What can i do in order to see it? I just want to test it really acquires a controlling terminal or not.
When i used ioctl and TIOCSCTTY, it never succeeds since there is no any valid fd to pass as a parameter.