Shebang and process name

In a regular distro, I have a script script with a shebang line #!/usr/bin/python. Then, when I start it, it starts in a process called script. It can handle interrupts, so I can then run pkill -USR1 script to activate a function in the script.

In NixOS, a shebang line of #!\usr\bin\env python breaks this workflow, as it then names the process python, so sending these interrupts becomes more complicated.

I can’t manually find the pid to send the signal to every time, so how can the script work?

you can write or wrap your script in a Nix derivation, then you can set an absolute path to the python binary in the nix store in the shebang using string interpolation: ''#!{pkgs.python3}/bin/python''

1 Like

using pgrep -f python you can match full command line, including full path if you want, and even use regex, and send a signal. It’s the proper way to handle your case.

1 Like