I have a Linux Kernel Module using Netlink in order to communicate with a daemon process running in the userspace.
During the development phase I have always run the daemon executable like a normal process (without calling fork()
) and all was working fine.
As of now the development of the main behavior is finished so I'm implementing an --daemon
argument that call the fork()
method (and also setsid()
as described in the link http://www.thegeekstuff.com/2012/02/c-daemon-process/) just before to continue the normal process.
The next step is that the daemon after having initialized a Netlink socket call the Linux Kernel Module and this one is saving the PID of the daemon in order to push messages.
The Linux Kernel Daemon receive correctly the messages from the daemon process but is not able to send messages using netlink_unicast()
that returns errno -111 (Connection refused).
I have check the PID received by the Linux Kernel Module and it is the same of the daemon after having been forked so looks correct.
Do you know why my daemon process, when forked, is no more able to receive messages (using the recvmsg()
method) from my Linux Kernel Module ?