From Kx Wiki
Jump to: navigation, search

The wiki is moving to a new format and this page is no longer maintained. You can find the new page at

The wiki will remain in place until the migration is complete. If you prefer the wiki to the new format, please tell the Librarian why.

kdb+ under inetd/xinetd

Felix LUNGU,


On *nix like operating system, inetd (or its successor xinetd) maintains a list of passive sockets for various services configured to run on that particular machine.

When a client attempts to connect to one of the service, inetd will start a program to handle the connexion based on the configuration files.

This way, inetd will run the server programs as they are needed by spawning multiple processes to service multiple network connexions.

Starting with 2.4 version of kdb+, a kdb+ database server can work under inetd to provide a private server for each connexion established on a designated port.

For Windows (NT/XP) you might be able to have kdb+ run under inetd using either Microsoft SFU (Services For Unix) or Cygwin.

Microsoft SFU:



To configure a kdb+ server to work under inetd or xinetd you have to decide over a name of the service and port on which this server should run and declare it in the /etc/services configuration file.

Note: this operations can be performed only by an administrative user (root).


# Local services
kdbtaq          2015/tcp	# kdb server for the taq database

If you have multiple databases which should be served over inetd, add multiple entries in the /etc/services file and make sure you are using different ports for each service name.

Also, as a safety measure, I would recommend to create one applicative group (ex: kdb) and two applicative users on your system, one owning the kdb+ programs (ex: kdb) and the databases and another one (ex: kdbuser) having the rights to execute and read data from the database directories.

This can be achieved by assigning the two users to applicative group mentioned above and set the permissions on the programs to be readable and executable by the group and the database directories readable and executable (search) by the group: rwxr-x---.

Once this is configured, you'll need to configure inetd/xinetd to make it aware of the new service.

If you are running inetd, you'll need to add the service configuration into /etc/inetd.conf (please have a look into inedt.conf man page for more details).


kdbtaq   stream  tcp   nowait kdbuser  /home/kdb/q/l64/q   q /home/kdb/taq -s 4

For xinetd, you'll need to create a configuration file (kdbtaq for example) for the new service in /etc/xinetd.d directory (please have a look at xinetd.conf man page for more details).


# default: on

service kdbtaq
    flags       = REUSE
    socket_type = stream
    wait        = no
    user        = kdbuser
    env         = QHOME=/home/kdb/q QLIC=/home/kdb/q
    server      = /home/kdb/q/l64/q
    server_args = /home/kdb/taq -s 4 -q -g 1
# use taskset to conform to license
#    server      = /bin/taskset
#    server_args = -c 0,1 /home/kdb/q/l64/q -q -g 1
#    only_from   = localhost
#    bind        =
#    instances   = 5
#    per_source  = 2

After the configuration is finished, you will have to find your process id for you inetd/xinetd server and send it the SIGHUP signal to read the new configuration:

$ ps -e|grep inetd
 3848 ?        00:00:00 xinetd
$ kill -HUP 3848

Also see

0. System Commands Reference

for stdout/stderr redirect.

Personal tools