summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/common-utils.c
diff options
context:
space:
mode:
authorCsaba Henk <csaba@gluster.com>2011-05-26 03:32:27 +0000
committerAnand Avati <avati@gluster.com>2011-05-26 08:55:22 -0700
commit9072b817b0803f999081c6244b18a9ae8fb0234c (patch)
tree919d47d2ea6d42975dac3dd9293f925d6e7849e6 /libglusterfs/src/common-utils.c
parent302ad26982d1eb7762e743e14dda627ffb317379 (diff)
reimplement invocation of external programs with run API
Signed-off-by: Csaba Henk <csaba@gluster.com> Signed-off-by: Anand Avati <avati@gluster.com> BUG: 2562 (invoke external commands precisely with fork + exec) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2562
Diffstat (limited to 'libglusterfs/src/common-utils.c')
-rw-r--r--libglusterfs/src/common-utils.c59
1 files changed, 0 insertions, 59 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c
index e745ec0faf3..7cb389ba35d 100644
--- a/libglusterfs/src/common-utils.c
+++ b/libglusterfs/src/common-utils.c
@@ -1485,65 +1485,6 @@ get_checksum_for_file (int fd, uint32_t *checksum)
}
-/* One should pass the command here with command with full path,
- otherwise, execv will fail */
-int
-gf_system (const char *command)
-{
- int ret = -1;
- pid_t pid = 0;
- int status = 0;
- int idx = 0;
- char *dupcmd = NULL;
- char *arg = NULL;
- char *tmp = NULL;
- char *argv[100] = { NULL, };
-
- dupcmd = gf_strdup (command);
- if (!dupcmd)
- goto out;
-
- pid = fork ();
- if (pid < 0) {
- /* failure */
- goto out;
- }
- if (pid == 0) {
- /* Child process */
- /* Step 0: Prepare the argv */
- arg = strtok_r (dupcmd, " ", &tmp);
- while (arg) {
- argv[idx] = arg;
- arg = strtok_r (NULL, " ", &tmp);
- idx++;
- }
- /* Step 1: Close all 'fd' */
- for (idx = 3; idx < 65536; idx++) {
- close (idx);
- }
- /* Step 2: execv (); */
- ret = execvp (argv[0], argv);
-
- /* Code will not come here at all */
- gf_log ("", GF_LOG_ERROR, "execv of (%s) failed", command);
-
- kill (getpid(), SIGKILL);
- }
- if (pid > 0) {
- /* Current, ie, parent process */
- pid = waitpid (pid, &status, 0);
- if (WIFEXITED(status) && WEXITSTATUS(status) == EXIT_SUCCESS)
- ret = 0;
- else
- ret = -1;
- }
-out:
- if (dupcmd)
- GF_FREE (dupcmd);
-
- return ret;
-}
-
int
get_checksum_for_path (char *path, uint32_t *checksum)
{