News for hackers. Stuff that matters.
[deleted]
Re:Writing my own init with Go by chubot on Tuesday February 09, 2016 @01:05PM (#11067289)
Yes, but if you see my edit, even with GOMAXPROCS=1, you are still constrained to the syscall.ForkExec API, which severely limits the usefulness of an init program. Its entire purpose is to start processes in different states (i.e. with different UID, etc.)

Not sure what you mean by 2). If you're suggesting polling, then that sucks, because one important feature of an init system is to restart processes immediately.

All in all my point is that Go is a very poor language for this... worse than Python (which I also tried and ended up using). I think it's great that the author is experimenting though -- I think that's the only way to make these issues clear.

Re:Writing my own init with Go by ominous_prime on Tuesday February 09, 2016 @01:33PM (#11067538)
#1 is not equivalent to being single threaded (every go program is multithreaded), it just means there only 1 thread for user goroutines. Every call to wait will block and spawn a new thread. If you force it to stay on the same thread, you block the runtime, and your entire program.

An init system has to call wait, that's one of its primary tasks, especially on orphaned processes it inherits.

Re:Writing my own init with Go by noselasd on Tuesday February 09, 2016 @01:04PM (#11067274)
Option 1) is not feasible though, as you'll block your one thread.

Though I wonder if you can work around all this by using signalfd (http://man7.org/linux/man-pages/man2/signalfd.2.html) and have SIGCHLD delivered through normal file descriptors - I don't know the low levels of Go enough to know if you can integrate a raw file descriptor with its runtime, or whether messing with SIGCHLD causes other issues, but it might be worth pursuing.

Re:Writing my own init with Go by nteon on Tuesday February 09, 2016 @02:04PM (#11067794)
You could easily do a syscall to get a signalfd file descriptor, then call os.NewFile to turn that numerical FD into a Go *os.File (https://golang.org/pkg/os/#NewFile). It seems like that should work fine!