libmctProgrammer’s Manual

mct_init/fini(3)

Name

mct_init, mct_fini — Initialise MCT

Synopsis

#include <mct/mct.h>

struct mct *mct_init(const char *path);

int mct_fini(struct mct *mct);

Description

The mct_init() function initialises internal structures for the MCT library and returns a handle suitable for use with further calls.

An IPC connection is opened to an instance of mctd given by the argument path. This is an AF_LOCAL address representing a socket on the file system if a leading slash is present, or in the abstract namespace otherwise. Typically this is bp/mctd as per the default for mctd. See mctd for details.

The mct_fini() function closes the IPC connection and destroys the corresponding mct handle.

Return Value

The mct_init() function returns a valid handle on success. On failure this function returns NULL and errno is set accordingly.

The mct_fini() function returns 0 on success. On failure this function returns NULL and errno is set accordingly.

Errors

The mct_init() function may fail for any of the reasons malloc or the socket API produce.

In addition, mct_init() may fail for any of the reasons documented by mct_ipc.

In addition, mct_init() may fail for the following reasons:

ENAMETOOLONG

The path parameter is too long to fit into a sockaddr_un struct.

EINVAL

The IPC protocol is of an unsupported version and was rejected by mctd.

The mct_fini() function may fail for any of the reasons the socket API can produce.

In addition, mct_fini() may fail for the following reasons:

EISCONN

A call was made to mct_event_attach() without a corresponding call to mct_event_detach().

Files

bp/mctd AF_LOCAL abstract space

IPC address.

bp/mctl-XXXXXX AF_LOCAL abstract space

An internal address assigned by libmct as part of the IPC protocol. This is in the abstract namespace. The XXXXXX is substituted for randomly-generated identifiers by mktemp.

See Also

mctd, mct, mct_ipc, unix, mktemp.