#define INCL_DOSERRORS #define INCL_DOSFILEMGR #include <os2.h> APIRET APIENTRY DosSetRelMaxFH(PLONG pcbReqCount, PULONG pcbCurMaxFH);Service Program Name: QP0LLIB1
The DosSetRelMaxFH() function requests that the system change the maximum number of file descriptors for the calling process (job). The system preserves all file descriptors that are currently open.
A request to increase the maximum number of file descriptors by more than the system can accommodate will succeed. The resulting maximum will be the largest number possible, but will be less than what you requested.
A request to decrease the maximum number of file descriptors will succeed. The resulting maximum will be the smallest number possible, but may be more than what you expected. For example, assume that the current maximum is 200 and there are 150 open files. A request to decrease the maximum by 75 results in the maximum being decreased by only 50, to 150, to preserve the open file descriptors.
A request to decrease the maximum number of file descriptors to below 20 will succeed, but the maximum will never be decreased below 20.
To retrieve the current maximum number of file descriptors, without any side effects, the value pointed to by pcbReqCount should be set to zero.
No authorization is required.
If DosSetRelMaxFH() is not successful, the value that is returned is one of the following errors. The <bseerr.h> header file defines these values.
A general failure occurred.
This may result from damage in the system. Refer to messages in the job log for other possible causes.
A protection violation occurred.
A pointer passed to this function is not a valid pointer.
The system may send the following messages from this function.
Message ID | Error Message Text |
---|---|
CPE3418 E | Possible APAR condition or hardware failure. |
CPFA0D4 E | File system error occurred. Error number &1. |
CPF3CF2 E | Error(s) occurred during running of &1 API. |
CPF9872 E | Program or service program &1 in library &2 ended. Reason code &3. |
If your application uses DosSetRelMaxFH() to increase the maximum number of file descriptors beyond 200, you should consider defining your own value for the FD_SETSIZE macro prior to including <sys/types.h>. This is to ensure that the fd_set structure is defined with the correct number of bits to accommodate the actual maximum number of file descriptors.
See Code disclaimer information for information pertaining to code examples.
The following example increases the maximum number of file descriptors by two.
#define INCL_DOSERRORS #define INCL_DOSFILEMGR #include <os2.h> #include <stdio.h> void main() { long ReqCount = 0; /* Number to add to maximum */ /* file descriptor count. */ ulong CurMaxFH; /* New count of file descriptors. */ int rc; /* Return code. */ /* Find out what the initial maximum is.*/ if ( NO_ERROR == (rc = DosSetRelMaxFH(&ReqCount, &CurMaxFH)) { printf("Initial maximum = %d",CurMaxFH); ReqCount = 2; /* Set up to increase by 2. */ if (NO_ERROR == (rc = DosSetRelMaxFH(&ReqCount, &CurMaxFH)) { printf(" New maximum = %d",CurMaxFH); } } if (NO_ERROR != rc) { printf("Error = &d",rc); } }
Output:
Initial maximum = 200 New maximum = 202
Top | UNIX-Type APIs | APIs by category |