chan_exists()
Verify that a process or file channel exists.
Syntax
Parameters
Parameter | Definition |
---|---|
channel | process or file I/O channel name (shared channels) or number (local channels) that is being verified |
Description
The chan_exists() function checks for a local/shared channel and returns the values listed below.
Value | Description |
---|---|
0 | Channel does not exist. |
1 | Channel is opened successfully and is read/write enabled. |
1-r | The agent read fd is closed and returns -1. |
1-w | The buffer is not empty or the write fd of the process is closed and returns -1. |
1-rw | The channel is closed or the buffer is empty or the read fd of the agent and write fd of an process are closed and returns -1. |
The chan_exists() function return value can be used with condition variables for synchronizing one PSL process to wait until another has opened a channel using either the popen() or fopen() function.
Example
The following PSL statements use the chan_exists() function to verify that a file channel successfully opened:
if (chan_exists(chan)) {
print("Channel successfully opened \n");
}
else {
print("Error opening file \n");
}
close(chan);