execl()导致应用程序崩溃

时间:2013-07-14 20:14:15

标签: c windows exec tcc

我在Windows 7下使用TCC编译并运行了以下程序,导致应用程序崩溃:

#include <process.h>

int main(void)
{
    if (execlp("c:\\windows\\system32\\whoami.exe", "c:\\windows\\system32\\whoami.exe") < 0)
        perror("error");

    return 1;
}

以下是崩溃详情:

Problem signature:
Problem Event Name: APPCRASH
Application Name:   a.exe
Application Version:    0.0.0.0
Application Timestamp:  00000000
Fault Module Name:  msvcrt.dll
Fault Module Version:   7.0.7601.17744
Fault Module Timestamp: 4eeaf722
Exception Code: c0000005
Exception Offset:   0005b4fe
OS Version: 6.1.7601.2.1.0.256.1
Locale ID:  1033
Additional Information 1:   0a9e
Additional Information 2:   0a9e372d3b4ad19135b953a78882e789
Additional Information 3:   0a9e
Additional Information 4:   0a9e372d3b4ad19135b953a78882e789

为什么会这样,我该如何解决?

1 个答案:

答案 0 :(得分:3)

您忘记将execlp()的参数列表空终止。

参见例如http://linux.die.net/man/3/execlphttp://msdn.microsoft.com/en-us/library/vstudio/1kxct8h0.aspx