> Can we create daemons in go ,as i need to fork on each time this command
> ./binFile start is run and stop on ./binFile stop will stop all threads.
> I had a look at os.StartProcess() and exec package but will need to write
> a program two programs two achive task, one to handle the commands and
> other my main program which is not preferable.
> Is there any way we can easily fork like the one provided in C fork().
In general it's hard to fork a program that uses threads, because there
is no simple way to ensure that all the threads are in a consistent
> Using syscall.RawSyscall() is giving me Epoll unexpected fd=7
> pollServer: unexpected wakeup for fd=7 mode=w and is hanging my child
> process reason maybe accessing the fd which was created in parent process.
Note that Go already uses epoll internally. You should never use
RawSyscall for a system call that can block. You must use Syscall
> Go is internally doing process of forking as it gives us interface to
> start a process and run it using exec package so there should be a
> signal which we have to set before forking or some way to handle this
> which i am not able to dig it out.
I don't know what it is that you are trying to handle. If this is about
the general issue of creating a daemon process, I'll again mention
Forking to exec a program is a special case. It doesn't matter whether
threads are in a consistent state if you are about to call exec anyhow.
You just have to be very careful about the code that runs in the child
process after the fork but before the exec.