Browse Source

Some renaming. Move free(context). Remove clish_context_spawn_fd().

git-svn-id: https://klish.googlecode.com/svn/trunk@115 0eaa4687-2ee9-07dd-09d9-bcdd2d2dd5fb
Serj Kalichev 13 years ago
parent
commit
8c4cc0a30f
2 changed files with 8 additions and 21 deletions
  1. 2 4
      clish/shell.h
  2. 6 17
      clish/shell/shell_spawn.c

+ 2 - 4
clish/shell.h

@@ -326,11 +326,9 @@ conf_client_t *clish_shell__get_client(const clish_shell_t * instance);
 /* Context */
 typedef struct clish_context_s clish_context_t;
 
-int clish_context_wait(const clish_context_t * instance);
-clish_context_t *clish_context_spawn(const pthread_attr_t * attr,
+int clish_shell_wait(clish_context_t * instance);
+clish_context_t *clish_shell_spawn_stream(const pthread_attr_t * attr,
 	const clish_shell_hooks_t * hooks, void *cookie, FILE * istream);
-clish_context_t *clish_context_spawn_fd(const pthread_attr_t * attr,
-	const clish_shell_hooks_t * hooks, void *cookie, int fd);
 
 _END_C_DECL
 #endif				/* _clish_shell_h */

+ 6 - 17
clish/shell/shell_spawn.c

@@ -138,8 +138,6 @@ static void clish_shell_cleanup(clish_context_t * context)
 		context->prompt = NULL;
 	}
 
-	/* finished with this */
-	free(context);
 #ifdef __vxworks
 	pthread_setcancelstate(last_state, &last_state);
 #endif				/* __vxworks */
@@ -300,12 +298,14 @@ _clish_shell_spawn_and_wait(const clish_shell_hooks_t * hooks,
 	if (context) {
 		/* join the shell's thread and wait for it to exit */
 		(void)pthread_join(context->pthread, &result);
+		/* finished with this */
+		free(context);
 	}
 	return result ? BOOL_TRUE : BOOL_FALSE;
 }
 
 /*-------------------------------------------------------- */
-int clish_context_wait(const clish_context_t * this)
+int clish_shell_wait(clish_context_t * this)
 {
 	void *result = NULL;
 
@@ -314,31 +314,20 @@ int clish_context_wait(const clish_context_t * this)
 
 	/* join the shell's thread and wait for it to exit */
 	(void)pthread_join(this->pthread, &result);
+	/* finished with this */
+	free(this);
 
 	return result ? BOOL_TRUE : BOOL_FALSE;
 }
 
 /*-------------------------------------------------------- */
-clish_context_t *clish_context_spawn(const pthread_attr_t * attr,
+clish_context_t *clish_shell_spawn_stream(const pthread_attr_t * attr,
 				     const clish_shell_hooks_t * hooks,
 				     void *cookie, FILE * istream)
 {
 	return _clish_shell_spawn(attr, hooks, cookie, istream);
 }
 
-
-/*-------------------------------------------------------- */
-clish_context_t *clish_context_spawn_fd(const pthread_attr_t * attr,
-				     const clish_shell_hooks_t * hooks,
-				     void *cookie, int fd)
-{
-	FILE *istream;
-
-	istream = fdopen(fd, "r");
-
-	return _clish_shell_spawn(attr, hooks, cookie, istream);
-}
-
 /*-------------------------------------------------------- */
 int clish_shell_spawn_and_wait(const clish_shell_hooks_t * hooks, void *cookie)
 {