From 8dfa77780fe1e3944a5b63b453e7a25b11ca25c4 Mon Sep 17 00:00:00 2001 From: Ethan Yonker Date: Thu, 4 Sep 2014 21:48:41 -0500 Subject: MTP: Use fork instead of pthread Change-Id: I95cf6f4def0c86f40c775738f0712323f0a0f146 --- mtp/twrpMtp.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'mtp/twrpMtp.cpp') diff --git a/mtp/twrpMtp.cpp b/mtp/twrpMtp.cpp index 6fe0ee3e8..e7c3f2cda 100755 --- a/mtp/twrpMtp.cpp +++ b/mtp/twrpMtp.cpp @@ -82,7 +82,7 @@ int twrpMtp::start(void) { return 0; } -pthread_t twrpMtp::runserver(void) { +pthread_t twrpMtp::threadserver(void) { pthread_t thread; ThreadPtr mtpptr = &twrpMtp::start; PThreadPtr p = *(PThreadPtr*)&mtpptr; @@ -90,6 +90,21 @@ pthread_t twrpMtp::runserver(void) { return thread; } +pid_t twrpMtp::forkserver(void) { + pid_t pid; + if ((pid = fork()) == -1) { + MTPE("MTP fork failed.\n"); + return 0; + } + if (pid == 0) { + // Child process + start(); + } else { + return pid; + } + return 0; +} + void twrpMtp::addStorage(std::string display, std::string path, int mtpid) { s = new storage; s->display = display; -- cgit v1.2.3