plogsrvd - Process logger daemon.


plogsrvd -h | [-f] [-v] [-e stderr|both|none] [-d log directory] [-m world|owner]


Plogsrvd is the daemon server for use with the plog client. It receives requests from the client and responds to them. For information about the nature of the requests, and an explanation of the logfiles kept, see plog(1). Plogsrvd uses a runtime directory (see below) for its unix local socket and into which output is written. Only one plogsrvd may exist for a given directory.


None of these are required.


Show usage message and version number then exit.

-e 'stderr', 'both' or 'none'

Where to log runtime errors. By default when run as a background process, plogsrvd uses syslog, prepending the pid of the instance to messages. If you specify 'stderr', errors will instead go to the plogsrvd's standard error stream. If you specify 'both', errors will go to syslog and the standard error stream; 'none' cancels any error reporting. Note that fatal initialization errors always go to stderr. There is an explanatory list of errors under ERRORS, below.


Run in foreground. Unless an explicit -e argument is given, this implies -e stderr, so that errors appear on the console.


This should be the full path to a directory into which log files will be written, and where the server socket will be located. The default is from the environment's PLOGDIR, if defined, or /var/local/plog. If the plogsrvd cannot access this directory at start-up (eg, because it does not exist, or permission is denied), a message will be reported on stderr and plogsrvd will exit.

-m 'world' or 'owner'

See COMMUNICATION MODE below; 'world' sets 777, 'owner' sets 700 (the default is 770).


Verbose operation. When set, the plogsrvd will issue timestamped non-error messages (eg, when a process is first logged) to its standard output stream. One of the other things reported are trapped signals such as SIGPIPE.


Linux's proc filesystem, which is where plogsrvd gathers its information, is very permissive: most files there are world readable. This means anyone can view the 'stat' data for any process. This is not true of the all the proc files, however. If some fields in the log are blank, this is either because your kernel does not report the information required, or because the plogsrvd does not have sufficient permissions to get it. Note that the uid of the plogsrvd need not be the same as the uid of the client which makes the request; see COMMUNICATION MODE below.


A feature of unix local sockets is that the client needs write permissions on the server socket to send a message to it. Plogsrvd uses a default mode of 770, meaning only clients with the same uid or gid will work. The -m switch can be used to override this (see INVOCATION OPTIONS, above); if it is not (i.e., the default 770 is used), the server attempts to set the gid of the socket to 'plog' and issues a message on standard error before forking if it cannot.

To help prevent mischievous or accidental deletion of the socket, plog's 'make install' sets the sticky bit (1000) on its runtime directory, /var/local/plog. A side effect of this is that users of the client won't be able to delete files there unless they have the same uid as the server.

If the socket already exists at startup, plogsrvd queries to make sure a server is not running using the same directory. To do this, it needs to create another local socket in /tmp, just as the plog client does. These are deleted immediately, but to prevent accumulation due to malfunction or misuse, plogsrvd will exit if it finds more than 25 of them in /tmp.

Note that plogsrvd can be run by anyone under their uid, if they include an appropriate -d option.


The recommended way to shut down plogsrvd is to send it SIGQUIT, SIGTERM, or SIGINT (e.g. via kill). Done thusly, it will clean up after itself by removing the server socket. You can also cause plogsrvd to exit by deleting the socket, but it will then report an error. You can get the pid of the plogsrvd using a particular socket/runtime directory by using the client -q switch, see plog(1).


When cleanly shutdown, plogsrvd returns 0. There is an enumeration of the other possible status codes in exitcodes.h from the source package. They correspond to and are reported as the ERRORS below.


Errors which occur during initialization are reported on the standard error stream. Unless otherwise noted, these are fatal:

$PLOGDIR or Runtime path is too long.

Unix local sockets must have a full path less than 108 bytes long. This includes the filename. Plogsrvd places this socket file in its runtime directory.

Could not change directory.

The runtime directory does not exist or does not have correct permissions.

Not enough memory.

Self-explanatory. Plogsrvd does not require much.

Set mode on socket failed.

The default (770) or desired (set with -m) mode could not be set on the server socket. This is NOT a fatal error, but it may affect plogsrvd's functionality (see COMMUNICATION MODE, above).

Failed to fork.

Plogsrvd could not fork and daemonize itself. This may reflect some unusual limitation on your system.

Could not create server or socket...

This should not normally happen, but if it does, it includes a further string error from the system.

Bind /tmp/.plog socket failed...

If plogsrvd cannot create a unix socket to use in its runtime directory because one exists there already, it tries to create one in /tmp in order to query the one in the runtime directory. This error indicates the /tmp socket could not be used; a further system string error hopefully explains why.

Query existing server failed.

This will happen if one user tries to start a plogsrvd in a directory currently occupied by another user's plogsrvd (or a stale socket left by one), and this user does not have write permission on that socket (see COMMUNICATION MODE above).

[N]+ /tmp/.plog sockets, exiting.

This refers to a situation where too many stale temporary sockets have been left around; see COMMUNICATION MODE above.

Plogsrvd already running on [runtime socket].

There is already a plogsrvd running in the runtime directory requested (/var/local/plog by default).

Could not remove stale socket...

If a plog server socket exists in the runtime directory requested, but no server appears to be using it, plogsrvd will try to delete the old socket and create a new one. This error indicates it could not be removed for the reason additionally reported.

[directory] is not an absolute path, sorry.

The runtime directory specified in PLOGDIR or via -d should be an absolute path.

There are several other fatal errors that can occur during runtime. By default, these will be reported to syslog (but see -e under INVOCATION OPTIONS, above).

Poll() failed...

Should be considered very unusual. This will happen if the internal poll(2) fails, or if the server socket has an error set subsequent to the poll. A further system string error may or may not provide an accurate explanation.

[runtime socket path] is gone.

Someone deleted the server socket ("plogd_sock") in the runtime directory.

Finally, there are non-fatal runtime errors. Some of these are redundant and may not indicate a real problem, depending on context:

When it shuts down, plogsrvd tries to remove the unix socket it was using. This will be reported if it could not remove it (possibly because it is already gone).

recvfrom() failed...

Much like 'Poll() failed', above, but non-fatal.

Can't read 'stat'/'statm'/'maps'...

This refers to a file in /proc. The corresponding process will no longer be monitored.

Short read on 'maps'...

May happen, very rarely, on some systems. This will cause plogsrvd to stop reporting anything beyond the "Dat+Stck" field, but only for this iteration.

Can't find log...

This is not an error if you removed a logfile in order to terminate logging of a process, but it gets reported anyway. The corresponding process will no longer be monitored.

Error checking files...

Plogsrvd tried to stat one of its own logfiles and failed, but not because the file is non-existent. The corresponding process for this error will no longer be monitored.

Too many files!

When plogsrvd creates a log file, it uses the base name of the process and the process pid. If such a file already exists, it adds .2, .3, .4, etc. However, there is a hardcoded limit of 999. You need to clean out the runtime directory.

Can't create/append logfile...

Possibly someone has changed the permissions on the runtime directory. A further system string error may explain. The corresponding process will no longer be monitored.

sendto([some socket path]) failed...

One reason for this is in parallel with "Query existing server failed", above.




Copyright (C) 2011, 2017 M. Eriksen. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation (