dbus-daemon tips

Original Address :: https://blog.csdn.net/jack0106/article/details/5588057/

 

related articles

1, DBus简介 ---- https://www.cnblogs.com/ningskyer/articles/9547933.html

2, linux-daemon process ---- the dbus https://blog.51cto.com/kasonbin/1352140

3, D-Bus daemon startup ---- https://blog.csdn.net/easebone/article/details/7336125

4, dbus-daemon tips ---- https://blog.csdn.net/jack0106/article/details/5588057

5, dbus-daemon under Linux What the hell? ---- https://bbs.csdn.net/topics/392608833

6、What is D-Bus?----https://www.freedesktop.org/wiki/Software/dbus/#index1h1

 

 

Please indicate the source and author Contact reprint
Article Source: http: //blog.csdn.net/jack0106
Author: Feng prop [email protected]

 

      dbus-daemon is a background process, responsible for forwarding the message. It's like a router. The most common procedure is in line with the dbus-based C / S structure.

      For example, we wrote two programs, A and B, where A is a client, B is the service. Suppose A to call a function C B, then the actual message flow direction is: A Tell dbus-daemon I want to call C functions B, and dbus-daemon is to call the C function B, and if C has a return value, then, The return value will tell B dbus-daemon, then the return value dbus-daemon then tells A. It can be seen, dbus-daemon is a background process is critical.

 

      With ubuntu, for example, under normal circumstances, there will be two dbus-daemon process, is part of a system, one part of the session, the two processes are started when the user logs in from the dbus-launch.

      Most common procedures, are using the session dbus-daemon, by default, A message is sent to this part of the session dbus-daemon.

 

 

      But in the debugging process, sometimes I want to see some more detailed information, so you can start them again a dbus-daemon, now there is a problem, the message of A is the flow of which dbus-daemon?

 

      In fact, dbus-daemon is the address, but there is an environment variable to represent it --DBUS_SESSION_BUS_ADDRESS, you can use the command env view. Our program, it is to rely on the environment variable to identify which one to use the dbus-daemon.

      When we logged into the desktop environment, the system startup script calls to dbus-launch to start a dbus-daemon, while this dbus-daemon will address given environment variable DBUS_SESSION_BUS_ADDRESS.

 

      Under normal circumstances, we need not consider DBUS_SESSION_BUS_ADDRESS, but there are times when a start dbus-daemon alone, the debugger helps.

      For example, suppose we still wrote two programs, A and B, where A is a client, B is the service. Also uses dbus self-start function (briefly explain, what is self-dbus start ---- A function to be called B, if B process has not started, dbus-daemon will automatically start up the first B process this is self-starting).

 

      Due to the use of self-service dbus-daemon process starts running mechanism, it is background processes, standard output has been redirected, and if B process has some print debugging information, it is difficult to directly view.
      This time, you can start a single dbus-daemon, so that A and B are using our own boot the dbus-daemon, this time, the dbus-daemon can also print the displayed information B.

 

 

      Dbus-daemon be started at a terminal, the command of the form as follows:
      DBUS_VERBOSE =. 1-dbus-daemon address --session --print

      In this case, the dbus-daemon will foreground, and prints out its address, the address form similar unix: abstract = / tmp / dbus-YcjSNNPJHg, guid = 18b385acdbd58611ffd3196b4beb69f0


      Then, in the implementation of our program A, to set the environment variable DBUS_SESSION_BUS_ADDRESS address value just obtained, for example, so that the program performs A:
      DBUS_SESSION_BUS_ADDRESS = UNIX: abstract = / tmp / dbus-YcjSNNPJHg, GUID = 18b385acdbd58611ffd3196b4beb69f0 ./a

 

      In this case, our program A and B, is to use our own to start the dbus-daemon to forward the message. At the same time, just start the terminal dbus-daemon, but also to print displayed information B.

 

      After understanding the above said this, you can also do more.
      dbus-launch is used to start the dbus-daemon script, it will print out the dbus-daemon address it started.

      Dbus to use all the technology program, will be used DBUS_SESSION_BUS_ADDRESS environment variable, so we can also use this environment variable to control the behavior of dbus-monitor.
----------------
Disclaimer: This article is CSDN bloggers 'jack0106' original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement. .
Original link: https: //blog.csdn.net/jack0106/article/details/5588057/

Published 136 original articles · won praise 306 · Views 4.37 million +

Guess you like

Origin blog.csdn.net/xqhrs232/article/details/103886650