How can I make a live time counter that ticks on the screen in parallel to part of a working program?
let’s say I have the following little sub code which run an internal program for a couple of minutes:
system (`compile command`);
exec "simu -sh";
While waiting it to end, can I open a fork or something that output to stdout a running clock time?
Another question may be, how can I output to screen the ALARM counter without hurt the rest of the script?
It is important to give context to your question. You already have two processes: a parent and a child. The child is replacing itself with the exec, so you can’t use the child to do any form of monitoring, but the parent is available. We just need to make the
waitpidcall non-blocking (i.e. it won’t wait to be successful, it will fail right away). This also gets rid of the need for theevalandalarmfunctions: