Movatterモバイル変換


[0]ホーム

URL:


man7.org > Linux >man-pages

Linux/UNIX system programming training


sd_bus_track_add_name(3) — Linux manual page

NAME |SYNOPSIS |DESCRIPTION |RETURN VALUE |NOTES |HISTORY |SEE ALSO |COLOPHON

SD_BUS_TRACK_ADD_NAME(3)  sd_bus_track_add_nameSD_BUS_TRACK_ADD_NAME(3)

NAME        top

       sd_bus_track_add_name, sd_bus_track_add_sender,       sd_bus_track_remove_name, sd_bus_track_remove_sender,       sd_bus_track_count, sd_bus_track_count_sender,       sd_bus_track_count_name, sd_bus_track_contains,       sd_bus_track_first, sd_bus_track_next - Add, remove and retrieve       bus peers tracked in a bus peer tracking object

SYNOPSIS        top

#include <systemd/sd-bus.h>int sd_bus_track_add_name(sd_bus_track*t, const char*name);int sd_bus_track_add_sender(sd_bus_track*t,sd_bus_message*message);int sd_bus_track_remove_name(sd_bus_track*t, const char*name);int sd_bus_track_remove_sender(sd_bus_track*t,sd_bus_message*message);unsigned sd_bus_track_count(sd_bus_track*t);int sd_bus_track_count_name(sd_bus_track*t, const char*name);int sd_bus_track_count_sender(sd_bus_track*t,sd_bus_message*message);int sd_bus_track_contains(sd_bus_track*t, const char*name);const char* sd_bus_track_first(sd_bus_track*t);const char* sd_bus_track_next(sd_bus_track*t);

DESCRIPTION        top

sd_bus_track_add_name()adds a peer to track to a bus peer       tracking object. The first argument should refer to a bus peer       tracking object created withsd_bus_track_new(3), the second name       should refer to a D-Bus peer name to track, either in unique or       well-known service format. If the name is not tracked yet it will       be added to the list of names to track. If it already is being       tracked and non-recursive mode is enabled, no operation is       executed by this call. If recursive mode is enabled a per-name       counter is increased by one each time this call is invoked, andsd_bus_track_remove_name()has to be called as many times assd_bus_track_add_name()was invoked before in order to stop       tracking of the name. Usesd_bus_track_set_recursive(3) to switch       from the default non-recursive mode to recursive mode, or back.       Note that the specified name is tracked as it is, well-known names       are not resolved to unique names by this call. Note that multiple       bus peer tracking objects may track the same name.sd_bus_track_remove_name()undoes the effect ofsd_bus_track_add_name()and removes a bus peer name from the list       of peers to watch. Depending on whether non-recursive or recursive       mode is enabled for the bus peer tracking object this call will       either remove the name fully from the tracking object, or will       simply decrement the per-name counter by one, removing the name       only when the counter reaches zero (see above). Note that a bus       peer disconnecting from the bus will implicitly remove its names       fully from the bus peer tracking object, regardless of the current       per-name counter.sd_bus_track_add_sender()andsd_bus_track_remove_sender()are       similar tosd_bus_track_add_name()andsd_bus_track_remove_name()       but take a bus message as argument. The sender of this bus message       is determined and added to/removed from the bus peer tracking       object. As messages always originate from unique names, and never       from well-known names this means that this call will effectively       only add unique names to the bus peer tracking object.sd_bus_track_count()returns the number of names currently being       tracked by the specified bus peer tracking object. Note that this       function always returns the actual number of names tracked, and       hence ifsd_bus_track_add_name()has been invoked multiple times       for the same name it is only counted as one, regardless of whether       recursive mode is used or not.sd_bus_track_count_name()returns the current per-name counter for       the specified name. If non-recursive mode is used this returns       either 1 or 0, depending on whether the specified name has been       added to the tracking object before, or not. If recursive mode has       been enabled, values larger than 1 may be returned too, in casesd_bus_track_add_name()has been called multiple times for the       same name.sd_bus_track_count_sender()is similar tosd_bus_track_count_name(), but takes a bus message object and       returns the per-name counter matching the sender of the message.sd_bus_track_contains()may be used to determine whether the       specified name has been added at least once to the specified bus       peer tracking object.sd_bus_track_first()andsd_bus_track_next()may be used to       enumerate all names currently being tracked by the passed bus peer       tracking object.sd_bus_track_first()returns the first entry in       the object, and resets an internally maintained read index. Each       subsequent invocation ofsd_bus_track_next()returns the next name       contained in the bus object. If the end is reachedNULLis       returned. If no names have been added to the object yetsd_bus_track_first()will returnNULLimmediately. The order in       which names are returned is undefined; in particular which name is       considered the first returned is not defined. If recursive mode is       enabled and the same name has been added multiple times to the bus       peer tracking object it is only returned once by this enumeration.       If new names are added to or existing names removed from the bus       peer tracking object while it is being enumerated the enumeration       ends on the next invocation ofsd_bus_track_next()asNULLis       returned.

RETURN VALUE        top

       On success,sd_bus_track_add_name()andsd_bus_track_add_sender()       return 0 if the specified name has already been added to the bus       peer tracking object before and positive if it has not. On       failure, they return a negative errno-style error code.sd_bus_track_remove_name()andsd_bus_track_remove_sender()return       positive if the specified name was previously tracked by the bus       peer tracking object and has now been removed. In non-recursive       mode, 0 is returned if the specified name was not being tracked       yet. In recursive mode-EUNATCHis returned in this case. On       failure, they return a negative errno-style error code.sd_bus_track_count()returns the number of names currently being       tracked, or 0 on failure.sd_bus_track_count_name()andsd_bus_track_count_sender()return       the current per-name counter for the specified name or the sender       of the specified message. Zero is returned for names that are not       being tracked yet, a positive value for names added at least once.       Larger values than 1 are only returned in recursive mode. On       failure, a negative errno-style error code is returned.sd_bus_track_contains()returns the passed name if it exists in       the bus peer tracking object. On failure, and if the name has not       been added yetNULLis returned.sd_bus_track_first()andsd_bus_track_next()return the first/next       name contained in the bus peer tracking object, andNULLif the       end of the enumeration is reached and on error.Errors       Returned errors may indicate the following problems:-EUNATCHsd_bus_track_remove_name()orsd_bus_track_remove_sender()           have been invoked for a name not previously added to the bus           peer object.-EINVAL           Specified parameter is invalid.-ENOMEM           Memory allocation failed.

NOTES        top

       Functions described here are available as a shared library, which       can be compiled against and linked to with thelibsystemd pkg-config(1) file.       The code described here usesgetenv(3), which is declared to be       not multi-thread-safe. This means that the code calling the       functions described here must not callsetenv(3) from a parallel       thread. It is recommended to only do calls tosetenv()from an       early phase of the program when no other threads have been       started.

HISTORY        top

sd_bus_track_add_name(),sd_bus_track_add_sender(),sd_bus_track_remove_name(),sd_bus_track_remove_sender(),sd_bus_track_count(),sd_bus_track_count_name(),sd_bus_track_count_sender(),sd_bus_track_contains(),sd_bus_track_first(), andsd_bus_track_next()were added in       version 232.

SEE ALSO        top

systemd(1),sd-bus(3),sd_bus_track_new(3)

COLOPHON        top

       This page is part of thesystemd (systemd system and service       manager) project.  Information about the project can be found at       ⟨http://www.freedesktop.org/wiki/Software/systemd⟩.  If you have a       bug report for this manual page, see       ⟨http://www.freedesktop.org/wiki/Software/systemd/#bugreports⟩.       This page was obtained from the project's upstream Git repository       ⟨https://github.com/systemd/systemd.git⟩ on 2025-08-11.  (At that       time, the date of the most recent commit that was found in the       repository was 2025-08-11.)  If you discover any rendering       problems in this HTML version of the page, or you believe there is       a better or more up-to-date source for the page, or you have       corrections or improvements to the information in this COLOPHON       (which isnot part of the original manual page), send a mail to       man-pages@man7.orgsystemd 258~rc2SD_BUS_TRACK_ADD_NAME(3)

Pages that refer to this page:sd-bus(3)sd_bus_track_new(3)systemd.directives(7)systemd.index(7)



HTML rendering created 2025-09-06 byMichael Kerrisk, author ofThe Linux Programming Interface.

For details of in-depthLinux/UNIX system programming training courses that I teach, lookhere.

Hosting byjambit GmbH.

Cover of TLPI


[8]ページ先頭

©2009-2025 Movatter.jp