a novel idea: a sh with a `fork" built-in?
whilst pushing a broom today, the following idea hit me:
# a super simple but conceptual example # a variable to communicate status between child/parent fork ALIVE if [ $? -eq -1 ]; then echo "$0: Unable to fork for ..., stopping $0" exit 255 elsif [ $? -ge 0 ]; then echo "doing processing: ... whatever" # when the child exits, the variable becomes false (and exits the loop) while [ $ALIVE ]; do echo '.' done echo 'done processing' else do lengthy processing in child exit 1 fi
like so much other software out there, my tpsh does synchronous execution of external commands by way of fork()'ing, followed by a wait() in the parent and an exec() in the child. ('&', job control, '[', and control flow are not implemented yet)
Then I thought, well hell, if the shell can fork stuff all day and we can use the & to execute programs asynchronously and move on - why shouldn't shell script be able to access the fork system call directly through a shell built in command? Implementing it shouldn't be much harder then the &, [, and control/flow stuff that needs doing anyway, and to me it sounds like an interesting feature/extension.
I was wondering if anyone else had an opinion on this idea.
Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.
Last edited by TerryP; 25th March 2009 at 03:44 AM.
|Thread||Thread Starter||Forum||Replies||Last Post|
|Keyboard with built in mouse trackball||blodan||FreeBSD General||2||21st June 2008 07:44 PM|