- How soon can I destroy the structure pointed to by
lpSecurityAttributes
passed toCreateNamedPipe()
? - Do I need a separate one for each pipe instance?
The MSDN documentation for CreateNamedPipe() says:
lpSecurityAttributes [in, optional]
A pointer to a SECURITY_ATTRIBUTES structure that specifies a security descriptor for the new named pipe...
Emphasis mine. Does 'new' mean new named pipe, or new instance of the named pipe? It goes on to say:
Remarks
To create an instance of a named pipe by using CreateNamedPipe, the user must have FILE_CREATE_PIPE_INSTANCE access to the named pipe object. If a new named pipe is being created, the access control list (ACL) from the security attributes parameter defines the discretionary access control for the named pipe.
(Again, emphasis mine.) One could read this as meaning that lpSecurityAttributes
is used only when creating the first instance of the named pipe (a new named pipe), and is ignored when creating further instances of the same named pipe. If so, then only one instance of the lpSecurityAttributes
structure is required.
Or maybe you have to pass in a valid lpSecurityAttributes for each instance, but it can (should?) be the same one?
Or perhaps you have to allocate a new SECURITY_ATTRIBUTES structure for each pipe instance?
My related question - can the SECURITY_ATTRIBUTES structure be destroyed as soon as the call to CreateNamedPipe()
returns or does it have to remain valid until the last handle (to the pipe, or just that pipe instance?) is closed - isn't even addressed.
Does anyone have definitive answers to these two questions?