uxstreamsocket - create a unix domain stream socket


uxstreamsocket [options] path program [arguments]


uxstreamsocket creates a unix domain stream 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:

-b, --backlog=N
Allow a backlog of N connections.

On some systems, n is silently limited to 5. On systems supporting SYN cookies, the backlog is irrelevant. The default is 20.

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

The default is 0622.

-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.

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.

uxstreamsocket 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.

uxstreamsocket 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.


uxstreammsocket sets the environment variables PROTO (to UXSTREAM) and UXSTREAMLOCALPATH (to path).


uxstreamsocket -r /dev/log setuidgid misclog unsyslogd




Uwe Ohse


Uwe Ohse homepage

IODP tools