<?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

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *