On Sat, Oct 17, 2015 at 12:38 PM, Laurent Bercot
<[email protected]> wrote:
> On 17/10/2015 09:47, Denys Vlasenko wrote:
>>
>> If you have a program which does not know that it is being run by
>> inotifyd,
>> you can create a shim which does know that:
>>
>> #!/bin/sh
>> PROG "$@"
>> test "$?" = 111 && kill $PPID
>
>
> Yes. You still have to know which program needs it and which one does
> not, and you have to run that shim for every program that does. This
> is code - a longer code path than Bartosz's patch, and that has to be
> maintained separately.
inotifyd syntax is "inotifyd PROG FILE1[:MASK]...",
and PROG is run with
PROG ACTUAL_EVENTS FILEn [SUBFILE]
This severely limits the number of unmodified PROGs you can run
to achieve some useful result. For example, even cat'ting newly
created files to stdout can't be done by PROG=cat, you need
to massage argv's
IOW: in practice, you always need a shim.
>> You propose to add complexity to inotifyd because it's looks "cleaner".
>> I don't see it as "cleaner", I see both ways as legitimate.
>> But your way requires additional code.
>
> It requires additional code in inotifyd, yes. But it factorizes code
> that you would have had to run anyway, in scripting the child. It also
> allows you to make the natural assumption that a child cannot impact
> its parent (except by returning a certain exit code), which I find
> makes scripts easier to understand, so more maintainable.
Sorry, but I don't agree to this view even after you repeat it.
Here is an example where this idiom of "killing the parent"
is used already:
busybox/examples/var_service/ntpd/ntp.script
...
if test x"$1" = x"unsync"; then
# No replies for our NTP requests were seen for some time.
#
# Among more mundate cases like network outages, this happens
# if we ran for a LONG time (days) and ntp server's IP has changed.
# ntpd has no code to re-resolve peers' addresses to IPs,
# we need to help it:
#
echo "$dt: $1"\
"syncronization lost, restarting ntpd"\
>>"$0.log.$$"
mv -- "$0.log.$$" "$0.log"
kill $PPID
exit
fi
...
Can you point me to the software you are working on so that
I can look on a wider picture of the problem you are trying to solve?
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox