sevlyar / go-daemon

A library for writing system daemons in golang.
MIT License
2.18k stars 246 forks source link

Add Credential struct to daemon_stub.go and daemon_unix.go #92

Open skrashevich opened 1 year ago

skrashevich commented 1 year ago

..for ability to compile the same code for windows and *nix systems

NorseGaud commented 7 months ago

Doesn't work on macos

❯ go run examples/cmd/gd-signal-handling/signal-handling.go
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x1003f80a0]

goroutine 1 [running]:
github.com/norsegaud/go-daemon.(*Context).parent(0x14000116c30)
        /Users/nathanpierce/go-daemon/daemon_unix.go:111 +0x1f0
github.com/norsegaud/go-daemon.(*Context).reborn(0x1400005cec0?)
        /Users/nathanpierce/go-daemon/daemon_unix.go:69 +0x58
github.com/norsegaud/go-daemon.(*Context).Reborn(...)
        /Users/nathanpierce/go-daemon/daemon.go:31
main.main()
        /Users/nathanpierce/go-daemon/examples/cmd/gd-signal-handling/signal-handling.go:51 +0x67c
exit status 2
skrashevich commented 7 months ago

Doesn't work on macos

❯ go run examples/cmd/gd-signal-handling/signal-handling.go
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x1003f80a0]

goroutine 1 [running]:
github.com/norsegaud/go-daemon.(*Context).parent(0x14000116c30)
        /Users/nathanpierce/go-daemon/daemon_unix.go:111 +0x1f0
github.com/norsegaud/go-daemon.(*Context).reborn(0x1400005cec0?)
        /Users/nathanpierce/go-daemon/daemon_unix.go:69 +0x58
github.com/norsegaud/go-daemon.(*Context).Reborn(...)
        /Users/nathanpierce/go-daemon/daemon.go:31
main.main()
        /Users/nathanpierce/go-daemon/examples/cmd/gd-signal-handling/signal-handling.go:51 +0x67c
exit status 2

Do you run it from root?

NorseGaud commented 7 months ago

Doesn't work on macos

❯ go run examples/cmd/gd-signal-handling/signal-handling.go
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x1003f80a0]

goroutine 1 [running]:
github.com/norsegaud/go-daemon.(*Context).parent(0x14000116c30)
        /Users/nathanpierce/go-daemon/daemon_unix.go:111 +0x1f0
github.com/norsegaud/go-daemon.(*Context).reborn(0x1400005cec0?)
        /Users/nathanpierce/go-daemon/daemon_unix.go:69 +0x58
github.com/norsegaud/go-daemon.(*Context).Reborn(...)
        /Users/nathanpierce/go-daemon/daemon.go:31
main.main()
        /Users/nathanpierce/go-daemon/examples/cmd/gd-signal-handling/signal-handling.go:51 +0x67c
exit status 2

Do you run it from root?

No

sevlyar commented 6 months ago

@skrashevich, i don't understand what purpose of the changes. Could you provide me more context or example?

skrashevich commented 6 months ago

@skrashevich, i don't understand what purpose of the changes. Could you provide me more context or example?

https://github.com/AlexxIT/go2rtc/commit/5c40ba0d457f65866d7592f4f98c9613fccdc67d

because os.syscall package provide Credential type for unix , but doesn't provide it for windows

sevlyar commented 6 months ago

The PR changes public interface of the library and breaks backward compatibility.