Version 4 of fork

Updated 2005-07-06 23:41:28

Expect includes a fork. So does TclX.

Example:

    for {set i 0} {$i < 100} {incr i} {
        set pid [fork]
        switch $pid {
            -1 {
                puts "Fork attempt #$i failed."
            }
            0 {
                puts "I am child process #$i."
                exit
            }
            default {
                puts "The parent just spawned child process #$i."
            }
        }
    }

An other example script using fork is a unix style daemon.


stevel offers a version in Critcl

    package provide fork 1.0
    package require critcl

    critcl::cproc fork {} int {
        return fork();
    }

Category Example