<?php

    $key = ftok ( __FILE__, "q" );
    $semaphore = sem_get ( $key, 1 );

    if ( sem_acquire ( $semaphore, 1 ) !== false )
    {
        while ( true )
        {
            sleep ( 1 );
            echo "proc\n";
        }
        sem_release ( $semaphore );
    }
    else
    {
        echo "Another process is running\n";
    }

?>

Categories: PHP language

152 Comments

Leave a Reply

Avatar placeholder