NAME
Systemd::Daemon::XS - Perl bindings to libsystemd.
VERSION
Version 0.06_02, released on 2015-10-23 08:22 UTC. This is a trial release.
SYNOPSIS
use Systemd::Daemon::XS qw{ :all };
sd_notify( 0, "READY=1\nSTATUS=Ready\n" );
sd_pid_notify( $pid, 0, "RELOADING=1" );
if ( sd_booted() ) {
...;
};
...;
DESCRIPTION
This module provides Perl bindings to the part of libsystemd shared library declared in <systemd/sd-daemon.h> header.
EXPORT
The module exports nothing by default. You have to specify symbols to import explicitly:
# Import function sd_listen_fds and constant SD_LISTEN_FDS_START:
use Systemd::Daemon::XS qw{ sd_listen_fds SD_LISTEN_FDS_START };
or use tags to import groups of related symbols:
# The same as as above:
use Systemd::Daemon::XS qw{ :sd_listen };
Either colon (:
) or dash (-
) can be used as tag prefix:
# The same as as above:
use Systemd::Daemon::XS qw{ -sd_listen };
The module uses Exporter::Tiny to export symbols, so all advanced import features like renaming symbols, import to another package, import to a hash, importing by regexp, etc, can be used:
use Systemd::Daemon::XS 'SD_ERR' => { -as => 'ERR' }, 'SD_DEBUG' => { -as => 'DBG' };
use Systemd::Daemon::XS qw{ -all !sd_notify };
See tips and tricks.
Tags
The module defines following export tags (all
tag is not listed):
- sd_booted
-
sd_booted.
- sd_is
-
sd_is_fifo, sd_is_mq, sd_is_socket, sd_is_socket_inet, sd_is_socket_unix, sd_is_special.
- sd_listen
-
SD_LISTEN_FDS_START, sd_listen_fds.
- sd_log
-
SD_ALERT, SD_CRIT, SD_DEBUG, SD_EMERG, SD_ERR, SD_INFO, SD_NOTICE, SD_WARNING.
- sd_notify
-
sd_notify, sd_pid_notify.
- sd
-
All above.
CONSTANTS
SD_ALERT
SD_CRIT
SD_DEBUG
SD_EMERG
SD_ERR
SD_INFO
SD_NOTICE
SD_WARNING
See sd-daemon(3).
SD_LISTEN_FDS_START
See sd_listen_fds(3).
FUNCTIONS
int sd_listen_fds( int unset_environment );
See sd_listen_fds(3).
int sd_notify( int unset_environment, const char * state );
// int sd_notifyf( int unset_environment, const char * format, ... );
int sd_pid_notify( pid_t pid, int unset_environment, const char * state );
// int sd_pid_notify_with_fds( pid_t pid, int unset_environment, const char * state, const int * fds, unsigned n_fds );
// int sd_pid_notifyf( int pid, int unset_environment, const char * format, ... );
See sd_notify(3) for details.
The binding for sd_pid_notify_with_fds
function is not yet implemented.
The bindings for sd_notifyf
and sd_pid_notifyf
will not be implemented likely. These printf
-like functions accept format string and variable argument list. They are quite convenient in C, but in Perl they do not have much value — they may be easily replaced either by string interpolation and/or by using sprintf
function, e. g.:
sd_notify( 0, "STATUS=Done $percent\%.\n" );
sd_notify( 0, sprintf( "STATUS=Done %03d\%.\n", $percent ) );
Also, it can be reimplemented in Perl:
sub sd_notifyf($$@) {
return sd_notify( shift( @_ ), sprintf( @_ ) );
}
Such implementation is not included into Systemd::Daemon::XS
because it is not a binding to libsystemd
.
int sd_booted();
See sd_booted(3).
int sd_is_fifo( int fd, const char * path );
int sd_is_mq( int fd, const char * path );
int sd_is_socket( int fd, int family, int type, int listening );
int sd_is_socket_inet( int fd, int family, int type, int listening, uint16_t port );
int sd_is_socket_unix( int fd, int family, int type, int listening, const char * path, size_t length );
int sd_is_special( int fd, const char * path );
See sd_is_fifo(3).
// int sd_watchdog_enabled( int unset_environment, uint64_t * usec );
The binding for sd_watchdog_enabled
function is not yet implemented.
SEE ALSO
AUTHOR
Van de Bugger <van.de.bugger@gmail.com>
COPYRIGHT AND LICENSE
Copyright (C) 2015 Van de Bugger
License GPLv3+: The GNU General Public License version 3 or later <http://www.gnu.org/licenses/gpl-3.0.txt>.
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.