golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.62k stars 17.61k forks source link

os,os/signal: documentation issue with Notify(), syscall.SIGTERM, and CTRL_CLOSE_EVENT/CTRL_LOGOFF_EVENT/CTRL_SHUTDOWN_EVENT #69847

Closed ucirello closed 1 week ago

ucirello commented 1 week ago

Go version

go1.23

Output of go env in your module/workspace:

Not applicable

What did you do?

I am trying to understand how Go handles signals on Windows.

What did you see happen?

When I read https://pkg.go.dev/os/signal?GOOS=windows#hdr-Windows, I see:

Additionally, if Notify is called, and Windows sends CTRL_CLOSE_EVENT, CTRL_LOGOFF_EVENT or CTRL_SHUTDOWN_EVENT to the process, Notify will return syscall.SIGTERM

However, in https://pkg.go.dev/syscall?GOOS=windows there is no syscall.SIGTERM.

What did you expect to see?

Probably, the documentation meant me to use https://pkg.go.dev/golang.org/x/sys/windows.

I would expect the os/signal to indicate that I should look for the package described above.

gabyhelp commented 1 week ago

Related Issues and Documentation

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

seankhliao commented 1 week ago

it does exist: https://cs.opensource.google/go/go/+/master:src/syscall/types_windows.go;l=65?q=SIGTERM&sq=&ss=go%2Fgo

ucirello commented 1 week ago

You are right @seankhliao -- sorry for my lack of attention to what I thought I saw.