exec.Command().Run() hang problem

I develop a http server in Go. It uses fineuplader to upload files to my fuse file system.

The fuse file system has a cache algorithm. If the cache is full, file write will wait cache available for 20 min. This makes the Go http server io.copy() waiting.

And the go http server has a routine work check some Linux service is active. I use following

cmd := exec.Command(“systemctl”, “is-active”, “–quiet”, servicename)
err := cmd.Run()

I found this routine work hang on cmd.Run() . It not 100% hang on, but have a very high fail rate.

I written a minimal reproducible example and put it on github GitHub - derentw/GoCmdHangExample

What I want to see is cmd.Output() run without delay.

I also try Go 1.14, and it also have this problem.

How does

$ systemctl is-active <servicename>

behave if you execute it in the shell of your OS? Does it hang, too?

No, it work well. Only Go process hang.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.