我在使用TerminateProcess. 我调用这个函数,进程仍然存在(在任务管理器中)。这段代码被多次调用,多次启动相同的 program.exe,这些进程在任务管理器中,我认为这并不好。实际上一直在创建两个进程:program.exe和conhost.exe。
我真的很感激任何帮助。
这是代码:
STARTUPINFO childProcStartupInfo;
memset( &childProcStartupInfo, 0, sizeof(childProcStartupInfo));
childProcStartupInfo.cb = sizeof(childProcStartupInfo);
childProcStartupInfo.hStdInput = hFromParent; // stdin
childProcStartupInfo.hStdOutput = hToParent; // stdout
childProcStartupInfo.hStdError = hToParentDup; // stderr
childProcStartupInfo.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
childProcStartupInfo.wShowWindow = SW_HIDE;
PROCESS_INFORMATION childProcInfo; /* for CreateProcess call */
bOk = CreateProcess(
NULL, // filename
pCmdLine, // full command line for child
NULL, // process security descriptor */
NULL, // thread security descriptor */
TRUE, // inherit handles? Also use if STARTF_USESTDHANDLES */ …Run Code Online (Sandbox Code Playgroud) 我的程序因检测到堆栈粉碎而失败,我从 Valgring 收到的唯一消息是“块可能在丢失记录中丢失”重复了三遍,我不知道如何解决。
==3726== 144 bytes in 1 blocks are possibly lost in loss record 74 of 87
==3726== at 0x4025315: calloc (vg_replace_malloc.c:467)
==3726== by 0x4010CD7: allocate_dtv (dl-tls.c:300)
==3726== by 0x401146B: _dl_allocate_tls (dl-tls.c:464)
==3726== by 0x40405C6: pthread_create@@GLIBC_2.1 (allocatestack.c:570)
==3726== by 0x806BF36: Thread::Thread(void* (*)(void*), void*) (os.cpp:203)
Run Code Online (Sandbox Code Playgroud)
这是代码,Valgrind 是 pthread_create 调用。
Thread::Thread( PFUNC func, void * arg )
{
int s = pthread_create( &_ThreadId, NULL, func, arg); //here is msg from valgrind
if (s != 0)
throw EXCEPT_NOTHREAD;
pthread_detach( _ThreadId );
} …Run Code Online (Sandbox Code Playgroud)