problem with PROGRAM
Hi,
I'm getting udev to work with a usb ethernet device (also Linux based) and Zeroconf.
What I need to do is run the autoipd daemon on network device usb0 when it appears, and remove autoipd when network device usb0 disappears.
adding was easy:
ACTION="add", PHYSDEVDRIVER="usbnet", PROGRAM="/usr/bin/autoipd -i %k"
My first attempt was to simply killall processes called autoipd. This works OK, but isn't the best method.
ACTION="remove", PHYSDEVDRIVER="usbnet", PROGRAM="/usr/bin/killall autoipd"
The second option was to kill only the autoipd process for usb0
ACTION="remove", PHYSDEVDRIVER="usbnet", PROGRAM="/usr/bin/cat /var/run/autoipd-usb0.pid | /usr/bin/xargs /bin/kill"
but this doesn't work and I don't know why. Am I allowed to use a pipe in the PROGRAM field?
regards,
Aras Vaichas
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 18 lines · Aras Vaichas
Hi,
I'm getting udev to work with a usb ethernet device (also Linux based) and Zeroconf.
What I need to do is run the autoipd daemon on network device usb0 when it appears, and remove autoipd when network device usb0 disappears.
adding was easy:
ACTION="add", PHYSDEVDRIVER="usbnet", PROGRAM="/usr/bin/autoipd -i %k"My first attempt was to simply killall processes called autoipd. This works OK, but isn't the best method.
ACTION="remove", PHYSDEVDRIVER="usbnet", PROGRAM="/usr/bin/killall autoipd"
Quoted 7 lines
The second option was to kill only the autoipd process for usb0
ACTION="remove", PHYSDEVDRIVER="usbnet", PROGRAM="/usr/bin/cat
/var/run/autoipd-usb0.pid|/usr/bin/xargs/bin/kill"but this doesn't work and I don't know why. Am I allowed to use a pipe in the PROGRAM field?
No, try putting that into a shell script. That should work properly.
thanks,
greg k-h
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
On Tue, Nov 29, 2005 at 11:39:18PM -0800, Greg KH was heard to remark:
Quoted 5 lines
Quoted 4 lines
ACTION="remove", PHYSDEVDRIVER="usbnet", PROGRAM="/usr/bin/cat
/var/run/autoipd-usb0.pid|/usr/bin/xargs/bin/kill"No, try putting that into a shell script. That should work properly.
I am guessing/hoping that quotes are escaped, so that the following might work:
ACTION="remove", PHYSDEVDRIVER="usbnet", PROGRAM="/bin/sh -c \"/usr/bin/cat /var/run/autoipd-usb0.pid | /usr/bin/xargs /bin/kill\" "
--linas
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 6 lines · linas
On Tue, Nov 29, 2005 at 11:39:18PM -0800, Greg KH was heard to remark:
Quoted 5 lines
Quoted 4 lines
ACTION="remove", PHYSDEVDRIVER="usbnet", PROGRAM="/usr/bin/cat
/var/run/autoipd-usb0.pid|/usr/bin/xargs/bin/kill"No, try putting that into a shell script. That should work properly.
And make sure that the udev event will return as fast as it can and not block with the external program. It may cause problems for other events, which wait for this event to come back.
Quoted 5 lines
I am guessing/hoping that quotes are escaped, so that the following might work:
ACTION="remove", PHYSDEVDRIVER="usbnet", PROGRAM="/bin/sh -c \"/usr/bin/cat
/var/run/autoipd-usb0.pid|/usr/bin/xargs/bin/kill\" "
No, escaping will not work, you need an external script. And PHYSDEVDRIVER is not a key, udev will recognize, it is just ignored, you probably want ENV{PHYSDEVDRIVER}=.
Kay
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 11 lines · Kay Sievers
Quoted 5 lines · linas
I am guessing/hoping that quotes are escaped, so that the following might work:
ACTION="remove", PHYSDEVDRIVER="usbnet", PROGRAM="/bin/sh -c \"/usr/bin/cat
/var/run/autoipd-usb0.pid|/usr/bin/xargs/bin/kill\" "No, escaping will not work, you need an external script. And PHYSDEVDRIVER is not a key, udev will recognize, it is just ignored, you probably want ENV{PHYSDEVDRIVER}=.
I took a look at udev_tools_run.c and I see why it doesn't work. I understand why it shouldn't work the way I was trying to make it work either. Thanks.
I also realised that running autoipd was leaving a zombie process that was stopping my remove rule from executing.
rule:
KERNEL="usb[0-9]", ACTION="add", ENV{PHYSDEVDRIVER}="usbnet", PROGRAM="/etc/udev/scripts/start_autoipd.sh %k"
start_autoipd.sh:
logger "$0 is attempting to start autoipd -i $1"
autoipd -i $1
logger "$0 successful"
exit 0
plug in the USB ethernet device:
/var/log/messages:
logger: /etc/udev/scripts/start_autoipd.sh is attempting to start autoipd -i usb0
logger: /etc/udev/scripts/start_autoipd.sh successful
# ps ax | grep autoipd 30554 ? Z< 0:00 [start_autoipd.s] <defunct> 30557 ? S<s 0:00 autoipd -i usb0 30562 pts/9 R+ 0:00 grep auto
The same happens if simply run autoipd like PROGRAM="/usr/bin/autoipd -i %k" Have I done something wrong, or should I be bothering the Howl/Zeroconf guys?
regards,
Aras Vaichas
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 3 lines · Aras Vaichas
rule:
KERNEL="usb[0-9]", ACTION="add", ENV{PHYSDEVDRIVER}="usbnet", PROGRAM="/etc/udev/scripts/start_autoipd.sh %k"
UPDATE:
I changed the rule from PROGRAM to RUN like so:
KERNEL="usb[0-9]", ACTION="add", ENV{PHYSDEVDRIVER}="usbnet", RUN+="/etc/udev/scripts/start_autoipd.sh %k"
and the process no longer becomes a zombie and it all appears to work correctly.
Why would PROGRAM cause this situation but RUN doesn't?
regards,
Aras Vaichas
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 7 lines · Aras Vaichas
Quoted 3 lines · Aras Vaichas
rule:
KERNEL="usb[0-9]", ACTION="add", ENV{PHYSDEVDRIVER}="usbnet", PROGRAM="/etc/udev/scripts/start_autoipd.sh %k"UPDATE:
Quoted 8 lines
I changed the rule from PROGRAM to RUN like so:
KERNEL="usb[0-9]", ACTION="add", ENV{PHYSDEVDRIVER}="usbnet", RUN+="/etc/udev/scripts/start_autoipd.sh %k"and the process no longer becomes a zombie and it all appears to work correctly.
Why would PROGRAM cause this situation but RUN doesn't?
PROGRAM is to request information from external programs to name a device. It is not to start or run anything else. RUN will run after the device node is created. But there is no real reason to behave differently in your case.
Again, make sure you are detaching immediately from the event process, and don't block longer than needed, not in PROGRAM, and not in RUN. It will cause problems for the event sequence handling. Start your program in the background and just exit.
Kay
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel