* problem with PROGRAM
@ 2005-11-30 6:47 Aras Vaichas
2005-11-30 7:39 ` Greg KH
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Aras Vaichas @ 2005-11-30 6:47 UTC (permalink / raw)
To: linux-hotplug
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_id\x16865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: problem with PROGRAM
2005-11-30 6:47 problem with PROGRAM Aras Vaichas
@ 2005-11-30 7:39 ` Greg KH
2005-11-30 16:43 ` linas
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Greg KH @ 2005-11-30 7:39 UTC (permalink / raw)
To: linux-hotplug
On Wed, Nov 30, 2005 at 05:47:43PM +1100, Aras Vaichas wrote:
> 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?
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_id\x16865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: problem with PROGRAM
2005-11-30 6:47 problem with PROGRAM Aras Vaichas
2005-11-30 7:39 ` Greg KH
@ 2005-11-30 16:43 ` linas
2005-11-30 23:29 ` Kay Sievers
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: linas @ 2005-11-30 16:43 UTC (permalink / raw)
To: linux-hotplug
On Tue, Nov 29, 2005 at 11:39:18PM -0800, Greg KH was heard to remark:
> >
> > 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_id\x16865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: problem with PROGRAM
2005-11-30 6:47 problem with PROGRAM Aras Vaichas
2005-11-30 7:39 ` Greg KH
2005-11-30 16:43 ` linas
@ 2005-11-30 23:29 ` Kay Sievers
2005-12-01 4:34 ` Aras Vaichas
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Kay Sievers @ 2005-11-30 23:29 UTC (permalink / raw)
To: linux-hotplug
On Wed, Nov 30, 2005 at 10:43:30AM -0600, linas wrote:
> On Tue, Nov 29, 2005 at 11:39:18PM -0800, Greg KH was heard to remark:
> > >
> > > 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.
> 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_id\x16865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: problem with PROGRAM
2005-11-30 6:47 problem with PROGRAM Aras Vaichas
` (2 preceding siblings ...)
2005-11-30 23:29 ` Kay Sievers
@ 2005-12-01 4:34 ` Aras Vaichas
2005-12-01 5:00 ` Aras Vaichas
2005-12-02 3:03 ` Kay Sievers
5 siblings, 0 replies; 7+ messages in thread
From: Aras Vaichas @ 2005-12-01 4:34 UTC (permalink / raw)
To: linux-hotplug
Kay Sievers wrote:
> On Wed, Nov 30, 2005 at 10:43:30AM -0600, linas wrote:
>>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_id\x16865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: problem with PROGRAM
2005-11-30 6:47 problem with PROGRAM Aras Vaichas
` (3 preceding siblings ...)
2005-12-01 4:34 ` Aras Vaichas
@ 2005-12-01 5:00 ` Aras Vaichas
2005-12-02 3:03 ` Kay Sievers
5 siblings, 0 replies; 7+ messages in thread
From: Aras Vaichas @ 2005-12-01 5:00 UTC (permalink / raw)
To: linux-hotplug
Aras Vaichas wrote:
> 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_id\x16865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: problem with PROGRAM
2005-11-30 6:47 problem with PROGRAM Aras Vaichas
` (4 preceding siblings ...)
2005-12-01 5:00 ` Aras Vaichas
@ 2005-12-02 3:03 ` Kay Sievers
5 siblings, 0 replies; 7+ messages in thread
From: Kay Sievers @ 2005-12-02 3:03 UTC (permalink / raw)
To: linux-hotplug
On Thu, Dec 01, 2005 at 04:00:49PM +1100, Aras Vaichas wrote:
> Aras Vaichas wrote:
> >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?
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_id\x16865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2005-12-02 3:03 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-30 6:47 problem with PROGRAM Aras Vaichas
2005-11-30 7:39 ` Greg KH
2005-11-30 16:43 ` linas
2005-11-30 23:29 ` Kay Sievers
2005-12-01 4:34 ` Aras Vaichas
2005-12-01 5:00 ` Aras Vaichas
2005-12-02 3:03 ` Kay Sievers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).