Skip to content
Advertisement

Bash on Ubuntu on Windows: Signal handler does not work

I try to run a simple program (code below), that should receive and handle the SIGUSR1 signal. It works well on “real” Linux, but if I run it on WSL after sending SIGUSR1 it prints

User defined signal 1

and terminates.

AFAIK this means that SIGUSR1 wasn’t handled by program and default handler was called. How can I make signal handling on WSL work properly?

Thanks in advance!

Source code:

JavaScript

Advertisement

Answer

The following proposed code:

  1. properly checks for errors
  2. properly sets up the struct sigaction
  3. cleanly compiles

And now, the proposed code:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement