NSH needs to call pthread_detach() to avoid memory leak

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5601 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2013-02-03 13:48:20 +00:00
parent 7f474703fa
commit a9f6de3d3b
2 changed files with 16 additions and 4 deletions

View File

@ -511,4 +511,6 @@
* apps/builtin/exec_builtin.c: Now uses task_spawn() to start
builtin applications.
* Type of argv has changed from const char ** to char * const *
* apps/nshlib/nsh_parse.c: Fix memory lead: Need to detach after
creating a pthread.

View File

@ -1426,8 +1426,10 @@ int nsh_parse(FAR struct nsh_vtbl_s *vtbl, char *cmdline)
/* Free the redirected output file path */
if (redirfile)
{
nsh_freefullpath(redirfile);
redirfile = NULL;
}
/* Save the result: success if 0; failure if 1 */
@ -1467,8 +1469,10 @@ int nsh_parse(FAR struct nsh_vtbl_s *vtbl, char *cmdline)
/* Free the redirected output file path */
if (redirfile)
{
nsh_freefullpath(redirfile);
redirfile = NULL;
}
/* Save the result: success if 0; failure if 1 */
@ -1596,6 +1600,12 @@ int nsh_parse(FAR struct nsh_vtbl_s *vtbl, char *cmdline)
goto errout;
}
/* Detach from the pthread since we are not going to join with it.
* Otherwise, we would have a memory leak.
*/
(void)pthread_detach(thread);
nsh_output(vtbl, "%s [%d:%d]\n", cmd, thread, param.sched_priority);
}
else