Kernel::System::PID

NAME

Kernel::System::PID – to manage PIDs

DESCRIPTION

All functions to manage process ids

PUBLIC INTERFACE

PIDCreate()

create a new process id lock

    $PIDObject->PIDCreate(
        Name         => 'PostMasterPOP3',  # (required)
        TimeDelay    => 123,               # (optional) If PID couldn't be created, attempt again after provided delay.
                                           #            Default 1 sec.
        AttemptCount => 1,                 # (optional) If PID couldn't be created, attempt again n times.
                                           #            Default 1 (doesn't attempt again).
    );

    or to create a new PID forced, without check if already exists (this will delete any process
    with the same name from any other host)

    $PIDObject->PIDCreate(
        Name  => 'PostMasterPOP3',
        Force => 1,
    );

    or to create a new PID with extra TTL time

    $PIDObject->PIDCreate(
        Name  => 'PostMasterPOP3',
        TTL   => 60 * 60 * 24 * 3, # for 3 days, per default 1h is used
    );

PIDGet()

get process id lock info

    my %PID = $PIDObject->PIDGet(
        Name => 'PostMasterPOP3',
    );

Returns:

    %PID = (
        ID      => 1234,
        Name    => 'Process name',
        PID     => 12345,
        Host    => 'localhost',
        Created => 1548861275,
        Changed => 1548861275,
    );

PIDDelete()

delete the process id lock

    my $Success = $PIDObject->PIDDelete(
        Name      => 'PostMasterPOP3',      # (required)
        ProcessID => 123,                   # (optional) delete only process with this PID
        Force     => 1,                     # (optional) force delete even if the PID is registered by another host.
                                            #            defaule 0.
    );

PIDUpdate()

update the process id change time. this might be useful as a keep alive signal.

    my $Success = $PIDObject->PIDUpdate(
        Name    => 'PostMasterPOP3',
    );
Scroll to Top