uxdgramsocket - create a unix domain datagram socket


uxdgramsocket [options] path program [arguments]


uxdgramsocket creates a unix domain datagram socket, binds it to path, and runs program with the remaining arguments.

options is a is a series of getopt or getopt_long style options. See below for more information.

The socket has the name path. If that file already exists it has to be deleted before the socket is created (you can use the -r / --remove-old-socket option for that). Note that deleting the file does not close any old instance of the socket, it will merely make it invisible (this means already connected sockets will stay connected).


Socket options:

-R, --unlink
Remove an existing (old) socket.

Use this if you are sure that no process still listings to an existing unix domain socket, or if you don't care.

-m, --mode=MODE
Set access rights of the socket to MODE.

The default is 0622.

Child program options:

-C, --chroot=DIR
Change the working directory to DIR. Then change the root directory of the process to . (the current directory). This will be done after the socket has been created and before changing the group or user ID.

-F, --fd=N
Move socket handle to file descriptor N.

`N' may be a whitespace or comma separated list. The default is to move it to 5. Note that moving the socket to file descriptor 2 may disturb the output of error messages.

-g, --gid=GID
Group ID to change to.

uxdgramsocket will switch to that group id after the socket has been set up. GID has to be a positive integer.

-u, --uid=UID
User ID to change to.

uxdgramsocket will switch to that user id after the socket has been set up. UID has to be a positive integer.

-U, --uidgid
The same as -u $UID -g $GID.

Usually used together with envuidgid.

Verbosity options:

Print the local port number.

After preparing to receive connections, print the local port number to standard output.

-q, --quiet
Quiet. Do not print error messages.

Print error messages.

This is the default.

-v, --verbose
Verbose. Print error and status messages.

Show version information.

Show a list of options or the long help on one.

The use with an argument shows the long helptext of that option, without an argument it will list all options.

Show longer help texts for all or one variable

The use with an argument shows the long help for this option, without arguments it shows the long description of all options.


uxdgramsocket sets the environment variables PROTO (to UXDGRAM) and UXDGRAMLOCALPATH (to path).


        uxdramsocket -r /dev/log setuidgid misclog unsyslogd




Uwe Ohse


Uwe Ohse homepage

IODP tools