Top |
void | gss_service_add_option_group () |
void | gss_service_run () |
void | gss_service_exit () |
GDBusConnection * | gss_service_get_dbus_connection () |
int | gss_service_get_exit_signal () |
guint | gss_service_get_inactivity_timeout () |
void | gss_service_set_inactivity_timeout () |
GDebugController * | gss_service_get_debug_controller () |
void | gss_service_hold () |
void | gss_service_release () |
A skeleton implementation of a system service, which exposes itself on the bus with a well-known name.
It follows the implementation recommendations in man 7 daemon
.
Since 0.2.0, it registers a D-Bus object at /org/freedesktop/Debugging
which exposes controls for debugging the service. Requests to these controls
from peers must be authorized. The default policy is to check against polkit
using the action ID set as “debug-controller-action-id”, if set.
If “debug-controller-action-id” is not set, requests to the debug object will be accepted unconditionally if the service is running on the D-Bus session bus, and rejected unconditionally if the service is running on the system bus.
void gss_service_add_option_group (GssService *self
,GOptionGroup *group
);
Add an option group to the command line options. The options in this group
will be listed in the help output, and their values will be set when
gss_service_run()
is called.
This is effectively a wrapper around g_option_context_add_group()
, so see the
documentation for that for more information.
Since: 0.1.0
void gss_service_run (GssService *self
,int argc
,char **argv
,GError **error
);
Run the service, and return when the process should exit. If it should exit
with an error status, error
is set; otherwise it should exit with exit code
zero (success).
This handles UNIX signals and command line parsing. If you wish to schedule
some work to happen asynchronously while gss_service_run()
is running in your
function, use main()
g_idle_add()
. This function, like the rest of the
library, is not thread-safe.
self |
||
argc |
number of arguments in |
|
argv |
argument array. |
[array length=argc] |
error |
return location for a GError |
Since: 0.1.0
void gss_service_exit (GssService *self
,const GError *error
,int signum
);
Cause the service to exit from gss_service_run()
. If error
is non-NULL
, the
service will exit with the given error; otherwise it will exit successfully.
If this is called multiple times, all errors except the first will be
ignored, so it may be safely used for error handling in shutdown code.
It is a programmer error to call this before startup_async()
has been called
on your service.
self |
||
error |
error which caused the process to exit, or |
[nullable] |
signum |
signal which caused the process to exit, or 0 for a successful exit |
Since: 0.1.0
GDBusConnection *
gss_service_get_dbus_connection (GssService *self
);
Get the GDBusConnection used to export the service’s well-known name, as specified in “bus-type”.
Since: 0.1.0
int
gss_service_get_exit_signal (GssService *self
);
Get the number of the signal which caused the GssService to exit.
Since: 0.1.0
guint
gss_service_get_inactivity_timeout (GssService *self
);
Get the value of “inactivity-timeout”.
Since: 0.1.0
void gss_service_set_inactivity_timeout (GssService *self
,guint timeout_ms
);
Set the value of “inactivity-timeout”.
Since: 0.1.0
GDebugController *
gss_service_get_debug_controller (GssService *self
);
Get the value of “debug-controller”.
Since: 0.2.0
void
gss_service_hold (GssService *self
);
Increase the hold count of the service, and hence prevent it from automatically exiting after the “inactivity-timeout” period expires with no activity.
Call gss_service_release()
to decrement the hold count. Calls to these two
methods must be paired; it is a programmer error not to.
Since: 0.1.0
void
gss_service_release (GssService *self
);
Decrease the hold count of the service, and hence potentially (if the hold count reaches zero) allow it to automatically exit after the “inactivity-timeout” period expires with no activity.
Call gss_service_hold()
to increment the hold count. Calls to these two
methods must be paired; it is a programmer error not to.
Since: 0.1.0
typedef struct _GssService GssService;
A skeleton implementation of a system service, which exposes itself on the bus with a well-known name.
It follows the implementation recommendations in man 7 daemon
.
Since: 0.1.0
struct GssServiceClass { GObjectClass parent_class; GOptionEntry *(*get_main_option_entries) (GssService *service); void (*startup_async) (GssService *service, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); void (*startup_finish) (GssService *service, GAsyncResult *result, GError **error); void (*shutdown) (GssService *service); };
Class structure for a GssService implementation.
All services must implement startup_async
, startup_finish
and shutdown
,
which are called by gss_service_run()
to start up and shut down the service.
If your service needs to support additional command line options in the main
group, implement get_main_option_entries
; otherwise leave it unimplemented.
Get a |
[nullable] | |
Asynchronous service startup implementation.
This should start performing the startup for the service, when called by
|
[not nullable] | |
Finish asynchronous startup started with
|
[not nullable] | |
Synchronous service shutdown implementation. This
should perform all shutdown for the service, and is called from
|
[not nullable] |
Since: 0.1.0
Errors from running a service.
Process was signalled with |
||
Invalid command line options. |
||
Bus or well-known name unavailable. |
||
Runtime environment is insecure or otherwise invalid for running the daemon. |
||
Inactivity timeout reached. |
Since: 0.1.0