diff options
author | Ethan Yonker <dees_troy@teamw.in> | 2014-09-05 04:48:41 +0200 |
---|---|---|
committer | Ethan Yonker <dees_troy@teamw.in> | 2014-09-05 04:59:20 +0200 |
commit | 8dfa77780fe1e3944a5b63b453e7a25b11ca25c4 (patch) | |
tree | 3d535c23f2a448761d390ed3148ec3c1f95b370a /mtp | |
parent | Fix reporting of folder size on exfat-fuse (diff) | |
download | android_bootable_recovery-8dfa77780fe1e3944a5b63b453e7a25b11ca25c4.tar android_bootable_recovery-8dfa77780fe1e3944a5b63b453e7a25b11ca25c4.tar.gz android_bootable_recovery-8dfa77780fe1e3944a5b63b453e7a25b11ca25c4.tar.bz2 android_bootable_recovery-8dfa77780fe1e3944a5b63b453e7a25b11ca25c4.tar.lz android_bootable_recovery-8dfa77780fe1e3944a5b63b453e7a25b11ca25c4.tar.xz android_bootable_recovery-8dfa77780fe1e3944a5b63b453e7a25b11ca25c4.tar.zst android_bootable_recovery-8dfa77780fe1e3944a5b63b453e7a25b11ca25c4.zip |
Diffstat (limited to '')
-rwxr-xr-x | mtp/twrpMtp.cpp | 17 | ||||
-rwxr-xr-x | mtp/twrpMtp.hpp | 3 |
2 files changed, 18 insertions, 2 deletions
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; diff --git a/mtp/twrpMtp.hpp b/mtp/twrpMtp.hpp index bed81c0e9..f0d8f4bfd 100755 --- a/mtp/twrpMtp.hpp +++ b/mtp/twrpMtp.hpp @@ -34,7 +34,8 @@ class twrpMtp { public: twrpMtp(int debug_enabled /* = 0 */); - pthread_t runserver(void); + pthread_t threadserver(void); + pid_t forkserver(void); void addStorage(std::string display, std::string path, int mtpid); private: int start(void); |