2 * Copyright 2015, Axel Dörfler, axeld@pinc-software.de.
3 * Distributed under the terms of the MIT License.
9 #include <TokenSpace.h>
10 #include <util/KMessage.h>
13 static port_id sLaunchDaemonPort
= -1;
17 BPrivate::get_launch_daemon_port()
19 if (sLaunchDaemonPort
< 0) {
20 sLaunchDaemonPort
= find_port(B_LAUNCH_DAEMON_PORT_NAME
);
23 if (get_port_info(sLaunchDaemonPort
, &info
) == B_OK
24 && info
.team
== find_thread(NULL
)) {
25 // Make sure that the launch_daemon doesn't wait on itself
26 sLaunchDaemonPort
= -1;
31 return sLaunchDaemonPort
;
36 BPrivate::send_request_to_launch_daemon(KMessage
& request
, KMessage
& reply
)
38 status_t status
= request
.SendTo(get_launch_daemon_port(),
39 B_PREFERRED_TOKEN
, &reply
);
43 return (status_t
)reply
.What();
48 BPrivate::get_launch_data(const char* signature
, KMessage
& data
)
50 BPrivate::KMessage
request(B_GET_LAUNCH_DATA
);
51 request
.AddString("name", signature
);
53 return BPrivate::send_request_to_launch_daemon(request
, data
);