From df744d5c9844cf7b1e61030b0ce3e69384e2d6a4 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 30 Aug 2014 23:43:58 -0400 Subject: [PATCH] Code Cleanup - Removed unused util.cpp ::execute variant. --- src/util.cpp | 56 ---------------------------------------------------- src/util.h | 1 - 2 files changed, 57 deletions(-) diff --git a/src/util.cpp b/src/util.cpp index 49699b744..ae7c0ef5a 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -393,62 +393,6 @@ void combine (std::vector & dest, const std::vector & source) std::sort (dest.begin (), dest.end ()); } -//////////////////////////////////////////////////////////////////////////////// -// Run an external executable with execvp. This means stdio goes to -// the child process, so that it can receive user input (e.g. passwords). -// -int execute (const std::string& executable, const std::vector& arguments) -{ - if (executable == "") - return -1; - - // create command line before forking because the parent process also needs this for - // calling context.debug () - char shell [] = "sh"; - char opt [] = "-c"; - - std::string cmdline = executable; - - std::vector ::const_iterator it; - for (it = arguments.begin (); it != arguments.end (); ++it) - cmdline += " " + (std::string) *it; - - context.debug ("Executing: " + std::string (shell) + " " + std::string (opt) + " " + cmdline); - - pid_t child_pid = fork (); - - if (child_pid == 0) - { - // this is done by the child process - char** argv = new char*[4]; - argv[0] = shell; // sh - argv[1] = opt; // -c - argv[2] = (char*) cmdline.c_str (); // e.g. scp undo.data user@host:.task/ - argv[3] = NULL; // required by execv - - int ret = execvp (shell, argv); - delete[] argv; - - exit (ret); - } - else if (child_pid == -1) - { - return -1; - } - else - { - // this is done by the parent process - int child_status; - - pid_t pid = waitpid (child_pid, &child_status, 0); - - if (pid == -1) - return -1; - else - return WEXITSTATUS (child_status); - } -} - //////////////////////////////////////////////////////////////////////////////// // Run a binary with args, capturing output. int execute ( diff --git a/src/util.h b/src/util.h index b77ae99b3..4631f7c0d 100644 --- a/src/util.h +++ b/src/util.h @@ -52,7 +52,6 @@ void uuid_unparse_lower (uuid_t uu, char *out); #endif const std::string uuid (); -int execute (const std::string&, const std::vector &); int execute (const std::string&, const std::vector &, const std::string&, std::string&); #ifdef SOLARIS