1

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 ?

ZedTuX
  • 2,859
  • 3
  • 28
  • 58
  • Why do they call `umask(0);`? I guess it is a permission issue. Why not use [daemon](http://man7.org/linux/man-pages/man3/daemon.3.html) instead of this *geekstuff* link? – artless noise Apr 08 '13 at 18:24
  • 1
    Yeah why not... I just found a link that looks good, but if daemon solve this issue, it's fine for me! Thank you, I'll try it and let you know – ZedTuX Apr 08 '13 at 21:35

1 Answers1

0

@artless-noise was right I forgotten to call umask(0);

ZedTuX
  • 2,859
  • 3
  • 28
  • 58