function __construct()
 {
     parent::__construct();
     $this->name = 'SampleTelnetServer';
 }
function Daemonize()
{
    //
    // We don't daemonize on windows
    //
    if (LsServer::GetOS() == LsServer::LS_SERVER_OS_WINDOWS) {
        return;
    }
    //
    // Clear file creation mask.
    //
    umask(0);
    //
    // Get the max number of file descriptors.
    //
    $limit = posix_getrlimit();
    //
    // Become a session leader to lose controlling TTY.
    //
    $pid = pcntl_fork();
    if ($pid < 0) {
        die("Could not fork daemon proces!\n");
    } else {
        if ($pid) {
            //
            // This is the parent process here. (the child pid is returned...)
            //
            echo "This is the parent process, exiting....\n";
            exit;
        }
    }
    if (posix_setsid() === -1) {
        die('could not setsid');
    }
    //
    // First child process executing here.  We ensure future
    // opens won't allocate controlling TTY's.
    //
    pcntl_signal(SIGTSTP, SIG_IGN);
    pcntl_signal(SIGTTOU, SIG_IGN);
    pcntl_signal(SIGTTIN, SIG_IGN);
    pcntl_signal(SIGHUP, SIG_IGN);
    // CHILD PROCESS EXECUTION FROM THIS POINT ON
    //*************************************************
    //*************************************************
    //
    // Change the working dir to root to keep from interfering
    // with any filesystem stuff.
    //
    if (chdir("/") != true) {
        die("Failure to chdir to /\n");
    }
    echo "This is the child; closing the fd's...\n";
    return EOK;
    //
    // Attach fd 0,1,2 to /dev/null to ignore input and output.
    //
    fclose(STDIN);
    fclose(STDOUT);
    fclose(STDERR);
    $stdIn = fopen('/dev/null', 'r');
    // set fd/0
    $stdOut = fopen('/dev/null', 'w');
    // set fd/1
    $stdErr = fopen('php://stdout', 'w');
    // a hack to duplicate fd/1 to 2
    return EOK;
}