commit 8dda7f313cf450ada3fa38fa757d12c75b546468
parent 9a43e93648520d4de735098cc2fe6d6593437616
Author: Kyle Milz <kyle@0x30.net>
Date: Sat, 14 Oct 2017 14:36:23 -0700
lib: use different program name for viewer process
Diffstat:
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/lib/lib_unix.c b/lib/lib_unix.c
@@ -170,6 +170,12 @@ citrun_start_viewer()
/* In parent process. */
return;
+ /*
+ * Use a different name than the instrumented program this library is
+ * linked to for better diagnostics in error messages.
+ */
+ setprogname("libcitrun");
+
/* In child process, exec the viewer. */
if (execlp("citrun_gl", "citrun_gl", NULL))
err(1, "exec citrun_gl");
diff --git a/t/lib_viewer.t b/t/lib_viewer.t
@@ -26,7 +26,7 @@ is( $? >> 8, 0, 'is wrapped compile exit code 0' );
my $inst_prog = Test::Cmd->new( prog => $wrap->workdir . "/main", workdir => '' );
$ENV{CITRUN_PROCDIR} = $inst_prog->workdir;
-my $err_good = 'main: exec citrun_gl: No such file or directory';
+my $err_good = 'libcitrun: exec citrun_gl: No such file or directory';
$inst_prog->run( chdir => $inst_prog->curdir );
is( $inst_prog->stdout, '', 'is case 1 stdout silent' );