Browse Source

D'oh d'oh d'oh d'oh d'oh d'oh d'oh d'oh d'oh

tags/v0.9.3
Michael Brown 18 years ago
parent
commit
a77b32aaf6
1 changed files with 9 additions and 3 deletions
  1. 9
    3
      src/core/exec.c

+ 9
- 3
src/core/exec.c View File

119
  * Execute the named command and arguments.
119
  * Execute the named command and arguments.
120
  */
120
  */
121
 int system ( const char *command ) {
121
 int system ( const char *command ) {
122
-	char *args = strdup ( command );
122
+	char *args;
123
 	int argc;
123
 	int argc;
124
-	
124
+	int rc;
125
+
126
+	/* Obtain temporary modifiable copy of command line */
127
+	args = strdup ( command );
125
 	if ( ! args )
128
 	if ( ! args )
126
 		return -ENOMEM;
129
 		return -ENOMEM;
127
 
130
 
134
 		
137
 		
135
 		split_args ( args, argv );
138
 		split_args ( args, argv );
136
 		argv[argc] = NULL;
139
 		argv[argc] = NULL;
137
-		return execv ( argv[0], argv );
140
+		rc = execv ( argv[0], argv );
138
 	}
141
 	}
142
+
143
+	free ( args );
144
+	return rc;
139
 }
145
 }

Loading…
Cancel
Save