Modify or query the flags associated with a connection
Synopsis:
#include <sys/neutrino.h>
int ConnectFlags( pid_t pid,
int coid,
unsigned mask,
unsigned bits );
int ConnectFlags_r( pid_t pid,
int coid,
unsigned mask,
unsigned bits );
Arguments:
- pid
- The ID of the process that the connection ID belongs to, or 0 for the current process.
- coid
- The ID of the connection whose flags you want to modify.
- mask
- A bitmap that indicates which bits are to be modified in the flags.
The bits currently defined include:
- _NTO_COF_CLOEXEC — close the connection if the
process calls an exec*() function to start a new process.
- _NTO_COF_INSECURE (QNX Neutrino 6.6 or later) — mark the connection as insecure.
The kernel sets this flag on a connection if the client program replaces its process image
(e.g., by calling exec*())
with a setuid or setgid binary.
If this flag is set on a connection, calls to
MsgDeliverEvent()
with an event type of SIGEV_MEMORY or SIGEV_THREAD
fail with an error of EACCES.
In QNX Neutrino 7.0 and later,
the server or client can set this flag if it doesn't trust the program at the other end of the connection,
but only the kernel can clear it.
Currently the flag stays set until the connection is detached.
- _NTO_COF_NOEVENT (QNX Neutrino 7.0 or later) — prevent the server from sending
sigevents over the channel to the client.
Only the client can clear this bit.
- _NTO_COF_NOSHARE (QNX Neutrino 7.1 or later) — this is an internal flag.
- _NTO_COF_REG_EVENTS (QNX Neutrino 7.0.1 or later; you can use ConnectFlags()
to set it in QNX Neutrino 7.1 or later) — reject the delivery of any
sigevents
that weren't registered as secure events with
MsgRegisterEvent().
- bits
- The new value of the flags.
Library:
libc
Use the -l c option to
qcc
to link against this library.
This library is usually included automatically.
Description:
The ConnectFlags() and ConnectFlags_r()
kernel calls modify or query the flags associated with the specified connection.
These kernel calls don't block.
These functions are identical except in the way they indicate errors.
See the Returns section for details.
You need to initialize the bits that correspond to the flag in both the
mask and bits arguments:
- If the bit in the mask is 1, and the bit in the bits
is 1, the function turns the flag on.
- If the bit in the mask is 1, and the bit in the bits
is 0, the function turns the flag off.
- If the bit in the mask is 0, the function doesn't change the current value
of the flag.
Note:
-
In order to change the connection flags on a coid for another process with a different user ID,
your process must have the PROCMGR_AID_CONNECTION ability enabled.
- In order to request information about another process,
your process must have the PROCMGR_AID_XPROCESS_QUERY ability enabled.
For more information, see
procmgr_ability().
Returns:
The previous value of the flags associated with the connection.
Note:
This value includes only the _NTO_COF_* bits listed above.
If an error occurs:
- ConnectFlags() returns -1 and sets
errno.
- ConnectFlags_r() returns the negative of a value from the Errors section
and doesn't set errno.
Errors:
- EBADF
- The coid isn't a valid connection ID for the process.
- EINVAL
- The mask includes invalid bits.
- EPERM
- The calling process doesn't have the required permission; see
procmgr_ability().
- ESRCH
- The process ID is invalid.
Classification:
QNX Neutrino
Safety: |
|
Cancellation point |
No |
Interrupt handler |
No |
Signal handler |
Yes |
Thread |
Yes |