MCPcopy Create free account
hub / github.com/dmtcp/dmtcp / _GetProgramExe

Function _GetProgramExe

jalib/jfilesystem.cpp:52–69  ·  view source on GitHub ↗

In Red Hat Enterprise Linux Server 5.4 (Linux kernel 2.6.18) For tests like dmtcp5, forkexec (tests with child processes), the child process may have a name "NAME (deleted)". This is arguably a bug in the kernel.

Source from the content-addressed store, hash-verified

50// the child process may have a name "NAME (deleted)".
51// This is arguably a bug in the kernel.
52dmtcp::string
53_GetProgramExe()
54{
55 dmtcp::string exe = "/proc/self/exe";
56
57 // NOTE: ResolveSymlink is returning string on stack. Hopefully
58 // C++ dmtcp::string is smart enough to copy it.
59 dmtcp::string exeRes = jalib::Filesystem::ResolveSymlink(exe);
60
61 JASSERT(exe != exeRes) (exe).Text("problem with /proc/self/exe");
62
63 // Bug fix for Linux 2.6.19
64 if (jalib::strEndsWith(exeRes.c_str(), DELETED_FILE_SUFFIX)) {
65 exeRes.erase(exeRes.length() - strlen(DELETED_FILE_SUFFIX));
66 }
67
68 return exeRes;
69}
70
71// Set buf, and return length read (including all null characters)
72int

Callers 1

GetProgramPathMethod · 0.85

Calls 2

strEndsWithFunction · 0.85
eraseMethod · 0.80

Tested by

no test coverage detected