libgslutil  1.2.3
Functions
Stale process checking.

Functions

void gsl_stale_get_tokens (uint32_t *tok_a, uint32_t *tok_b)
 Get tokens to signify current process is fresh. More...
 
void gsl_stale_get_nonprocess_tokens (uint32_t *tok_a, uint32_t *tok_b)
 Get tokens to signify no process associated with resource. More...
 
int gsl_is_stale (uint32_t tok_a, uint32_t tok_b)
 Check if process associated with tokens is stale. More...
 

Detailed Description

A set of routines which allow checking for stale processes. The function gsl_stale_get_tokens() is first called in the target process (the one being checked), and the resulting tokens are written into the file/resource that requires the check. Consumer processes then read these tokens and pass them to gsl_is_stale(), which will return 0 if the associated process is fresh or non-0 if stale.

Function Documentation

◆ gsl_stale_get_tokens()

void gsl_stale_get_tokens ( uint32_t *  tok_a,
uint32_t *  tok_b 
)

Get tokens to signify current process is fresh.

Parameters
[out]tok_aSet to first token.
[out]tok_bSet to second token.

This function returns two tokens for the current process which can be used by any other process on the system to determine if this process is still running (fresh) or has exited (stale).

The two tokens returned may be written to a file etc. and any other process on the same system can use them to determine stale/fresh information at any time.

◆ gsl_stale_get_nonprocess_tokens()

void gsl_stale_get_nonprocess_tokens ( uint32_t *  tok_a,
uint32_t *  tok_b 
)

Get tokens to signify no process associated with resource.

Parameters
[out]tok_aSet to first token.
[out]tok_bSet to second token.

A degenerate case of gsl_stale_get_tokens(), this returns two special tokens which can be used to denote a file or resource is not associated with a running process (and thus if passed to gsl_is_stale() the result will always indicate a fresh file/resource).

◆ gsl_is_stale()

int gsl_is_stale ( uint32_t  tok_a,
uint32_t  tok_b 
)

Check if process associated with tokens is stale.

Parameters
tok_aFirst token.
tok_bSecond token.
Return values
0on success (process is fresh).
1on fail (process is stale).

Given two tokens originally returned from gsl_stale_get_tokens(), checks to see if the process that originally created those tokens is still fresh or not.

If the process is still fresh, returns 0; otherwise, returns 1 (stale).