#3 [solved] Segmentation fault when running from udev rule

closed-invalid
nobody
None
5
2011-08-14
2011-08-12
Alcides Neto
No

Trying to start rejoystick automatically from a udev rule when the joystick connects, I get a segmentation fault.

My udev rule is really simple:
KERNEL=="js0", RUN+="/home/alcides/scripts/rejoystick.sh"

rejoystick.sh goes as follows:
#! /bin/sh
DISPLAY=:0
LOG="/tmp/rejoystick.log"

date >> $LOG
echo "$ACTION" >> $LOG

if [ "$ACTION" = "add" ]; then
/usr/games/rejoystick -d >> $LOG 2>&1
elif [ "$ACTION" = "remove" ]; then
/usr/bin/killall -9 rejoystick
fi

Running the script from SSH or another tty works as expected. I only get a segmentation fault when running from udev.

PS: Nice work on rejoystick. It works great. =) I'm gonna try the java version see if that works.

Discussion

  • Alcides Neto
    Alcides Neto
    2011-08-14

    Rookie mistake... udev rules are executed as root. I sudo'ed the rejoystick call to my user and it worked.

     
  • Alcides Neto
    Alcides Neto
    2011-08-14

    • summary: Segmentation fault when running from udev rule --> [solved] Segmentation fault when running from udev rule
    • status: open --> closed-invalid