Is it possible to enforce a certain exit code when using "kill" to stop a process?
Solution 1:
This will exit with a 42 if any of the listed signals are received. You could perform other actions including calling a function, etc.
#!/bin/bash
trap 'exit 42' SIGINT SIGQUIT SIGTERM
Solution 2:
Yes, you have the trap the kill signals you send to your script using the trap command, see man bash and look for the trap command.
After "trapping" the signal sent to the script, you could exit with any value you want to.