Skip to content

Commit

Permalink
Fix windows builds by separating out OS signal handling code per plat…
Browse files Browse the repository at this point in the history
…form
  • Loading branch information
Anthony Green committed Jan 3, 2024
1 parent 76162f5 commit 2c57ac4
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 7 deletions.
9 changes: 2 additions & 7 deletions green-orb.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// green-orb.go - an Observe and Report Buddy
//
// Copyright (C) 2023 Anthony Green - green@moxielogic.com
// Copyright (C) 2023, 2024 Anthony Green - green@moxielogic.com
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
Expand Down Expand Up @@ -315,12 +315,7 @@ func main() {
// Goroutine for passing signals
go func() {
for sig := range sigChan {
if sig == syscall.SIGCHLD {
continue
}
if err := observed_cmd.Process.Signal(sig); err != nil {
log.Println("green-orb error: Failed to send signal to subprocess:", err)
}
process_signal(observed_cmd, sig)
}
}()

Expand Down
45 changes: 45 additions & 0 deletions signals_unix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// +build linux darwin

// signals_unix.go - pass signals through to observed command
//
// Copyright (C) 2023, 2024 Anthony Green - green@moxielogic.com
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without
// restriction, including without limitation the rights to use, copy,
// modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
// BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

package main

import (
"log"
"os"
"os/exec"
"syscall"
)

func process_signal(observed_cmd *exec.Cmd, sig os.Signal) error {
if sig == syscall.SIGCHLD {
return nil
}
if err := observed_cmd.Process.Signal(sig); err != nil {
log.Println("green-orb error: Failed to send signal to subprocess:", err)
}

return nil
}
36 changes: 36 additions & 0 deletions signals_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// +build windows

// signals_windows.go - dummy placeholder
//
// Copyright (C) 2023, 2024 Anthony Green - green@moxielogic.com
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without
// restriction, including without limitation the rights to use, copy,
// modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
// BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

package main

import (
"os"
"os/exec"
)

func process_signal(observed_cmd *exec.Cmd, sig os.Signal) error {
return nil
}

0 comments on commit 2c57ac4

Please sign in to comment.