On Wed, 6 Sept 2023 at 11:38, Roberto A. Foglietta
<[email protected]> wrote:
> Moreover the execution of this function (preloaded into the
> environment) gives the same time consumption of the grep -E command
> without any appreciable delay.
To be fair the function should return the status like pidof and pgrep,
therefore a grep . should be added in pipe to the last command
comm_pid() {
local i str
test -n "${1:-}" || return 1
for i in "$@"; do str="$i${str:+|$str}"; done
grep -E "$str" /proc/[1-9]*/comm | cut -d/ -f3 | grep .
}
>
> redfishos:~ # a=$(date +%s%N); comm_pid yamui$; b=$(date +%s%N); echo $((b-a))
> 766
> 76270209
> redfishos:~ # echo $(( 76270209 / 1022910 ))%
> 74%
>
However, execution time does not change so much
redfishos:~ # a=$(date +%s%N); comm_pid yamui$; b=$(date +%s%N); echo $((b-a));
766
79261041
redfishos:~ # echo $(( 79261041 / 1022910 ))%
77%
Best regards, R-
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox