I have a Linux application which opens up several serial devices (/dev/ttyUSBX) and reads/writes from them. When I run it from a command prompt (Ubuntu 10.04, bash) it works perfectly.
$sudo ./my_program /dev/ttyUSB0 #sudo for permissions on the device
I want this program to run at startup, and be respawned if it dies - so I put it into the Upstart config (/etc/init/*) and called it "my_service".
When I reboot the machine, my_service executes and my_program runs. However, after a few seconds (right around when it's opening up the ttyUSB's and reading from them) my process receives a SIGINT. I cannot figure where it's coming from. It's not a permissions issue on the devices, they open() fine and a few bytes get transferred OK. Using waitsiginfo() I was able to get a si_code of 0x80, or SI_KERNEL. So I know it's not coming from another process, but from the kernel itself. Nobody has hit CTRL-C or ALT-CTL-DEL on the console - why is the kernel sending me a SIGINT?
Worse, my program appropriately exits based on this signal - is respawned by Upstart, and is promptly SIGINT'ed again! Is there any way to figure out where this signal is originating from and why? Is there some level of kernel debugging that could be enabled to shed some light on this? Why the different behaviour when started by Upstart vs. manually from bash?