Timercmp() searching example for macro

I am referring to this forum and the explanation about timeradd (3) where is written

"timercmp() compares a to b using the comparison operator given in CMP, and returns the
result of that comparison." I could not find any example for this kind of macro. It sounds
easy, comparing a to b, at first sight.

My attempt so far is this, but is there anyone who could give me an example with the above
timercmp () ??? Thanks in advance.

function timer
{
FINISH_TIME=`date +%s`
SECONDS=$((FINISH_TIME - START_TIME))
if [ "$SECONDS" -gt "$TIME_LIMIT" ]; then
notify-send "limit reached..." \ "Disconnect"
disconnect
fi
}

These functions are in manual section 3 which is the C function manual (only available to "C" code).

However the function you supply is most likely a bash/ksh function so you will not have these C functions available to call directly. Do you need microsecond accuracy on the compare, if not the code you have is fine.

1 Like

allright, I don't need nanoseconds or

%[p][l]S  

The number of CPU seconds spent in system mode.
Thanks a lot, not reinventing the wheel.