How can I call a Linux / UNIX system call in golang

For some reason, I need to call some system calls on the system (Linux). I checked the syscall package documentation and could not find anything about it.

Then I just saw a project ( https://github.com/AllenDang/w32/blob/master/kernel32.go ) that wraps windows apis. I read its source code a bit.

He uses

modkernel32 = syscall.NewLazyDLL("kernel32.dll") 

to load a dynamic library. However, there is no documentation for the NewLazyDLL () function

I am sure there should be a similar function for Linux / UNIX. Is there anyone who can tell me the name of the function or the way to call the Linux system call in the Golang or load functions from libc.so?

More details

I want to call the system call 'daemon' or 'fork' (I want to unmount the process) because I cannot find the golang library.

+6
source share
1 answer

There is currently no daemon style function in the Go standard library. There is an open error adding such a function , but it was postponed to version Go 1.1. I would suggest reading the error report for some reason, it is not as simple as it may seem.

There are other ways to start daemon processes, in addition to having the daemon plug itself. For example, modern init daemons, such as Upstart and Systemd, can control these daemon processes for you.

+4
source

All Articles