#include <boost/optional.hpp>
#include <boost/none.hpp>
+#include <config.h>
#include "TAFactory.h"
#include "UUIDUtils.h"
#include "ResponseCommands/ResMakeCommand.h"
{
char *argv[5];
string gdbserver = "/usr/bin/gdbserver";
- string port_str = "localhost:" + std::to_string(port);
+ string io_str = "-";
argv[0] = &gdbserver[0];
- argv[1] = &port_str[0];
+ argv[1] = &io_str[0];
argv[2] = &image_path[0];
argv[3] = &argument[0];
argv[4] = NULL;
pid = fork();
if (0 == pid) {
LOGD(MODULE_SIM_DAEMON, "In Child Process");
+ int err;
+ struct sockaddr_un addr = {
+ AF_UNIX,
+ DEBUGPROXY_SOCK_PATH,
+ };
+ int sock = socket(AF_UNIX, SOCK_STREAM, 0);
+ if (sock == -1) {
+ err = errno;
+ goto exit;
+ }
+ if (connect(sock, (struct sockaddr *) &addr, sizeof(addr)) == -1)
+ goto clean_socket;
+ if (write(sock, &port, sizeof(port)) == -1)
+ goto clean_socket;
+ if (dup2(sock, 0) == -1 ||
+ dup2(sock, 1) == -1)
+ goto clean_socket;
execv(argv[0], argv);
- LOGE(MODULE_SIM_DAEMON, "Launching Trusted Application FAILED");
+clean_socket:
+ err = errno;
+ close(sock);
+exit:
+ LOGE(MODULE_SIM_DAEMON, "Launching Trusted Application FAILED: %s", strerror(err));
pthread_mutex_unlock(&lock);
return false;
}