Skip to content

Commit

Permalink
Replace SIGUSR1 to SIGRTMIN+3
Browse files Browse the repository at this point in the history
  • Loading branch information
rockeet committed Jan 6, 2024
1 parent ad3f2e3 commit 7b99ed2
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,18 @@ import (
)

var log = GetLogger("main")
var SIGRTMIN = 34

func registerSIGINTHandler(fs *Goofys, flags *FlagStorage) {
// Register for SIGINT.
signalChan := make(chan os.Signal, 1)
signal.Notify(signalChan, os.Interrupt, syscall.SIGTERM, syscall.SIGUSR1)
signal.Notify(signalChan, os.Interrupt, syscall.SIGTERM, SIGRTMIN+3)

// Start a goroutine that will unmount when the signal is received.
go func() {
for {
s := <-signalChan
if s == syscall.SIGUSR1 {
if s == SIGRTMIN+3 {
log.Infof("Received %v", s)
fs.SigUsr1()
continue
Expand Down Expand Up @@ -76,7 +77,7 @@ var waitedForSignal os.Signal

func waitForSignal(wg *sync.WaitGroup) {
signalChan := make(chan os.Signal, 1)
signal.Notify(signalChan, syscall.SIGUSR1, syscall.SIGUSR2)
signal.Notify(signalChan, SIGRTMIN+3, syscall.SIGUSR2)

wg.Add(1)
go func() {
Expand Down Expand Up @@ -181,14 +182,14 @@ func main() {
if child != nil {
// attempt to wait for child to notify parent
wg.Wait()
if waitedForSignal == syscall.SIGUSR1 {
if waitedForSignal == SIGRTMIN+3 {
return
} else {
return fuse.EINVAL
}
} else {
// kill our own waiting goroutine
kill(os.Getpid(), syscall.SIGUSR1)
kill(os.Getpid(), SIGRTMIN+3)
wg.Wait()
defer ctx.Release()
}
Expand All @@ -213,7 +214,7 @@ func main() {
// fatal also terminates itself
} else {
if !flags.Foreground {
kill(os.Getppid(), syscall.SIGUSR1)
kill(os.Getppid(), SIGRTMIN+3)
}
log.Println("File system has been successfully mounted.")
// Let the user unmount with Ctrl-C
Expand Down

0 comments on commit 7b99ed2

Please sign in to comment.