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 ef5b52b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ var log = GetLogger("main")
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, syscall.SIGRTMIN+3)

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

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

0 comments on commit ef5b52b

Please sign in to comment.