Skip to content

Commit

Permalink
Merge pull request #219 from Vorschreibung/fix-linux-build-monitoring…
Browse files Browse the repository at this point in the history
…-double-output

prevent logging q3map2's output twice on linux with build monitoring
  • Loading branch information
Garux authored Oct 30, 2024
2 parents 679ebd9 + c100cc2 commit 3d41d8f
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion libs/commandlib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,15 @@

#include <cstdlib>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/wait.h>


bool Q_Exec( const char *cmd, char *cmdline, const char *, bool, bool waitfor ){
char fullcmd[2048];
char *pCmd;

pid_t pid;
#ifdef _DEBUG
printf( "Q_Exec damnit\n" );
Expand All @@ -54,6 +57,17 @@ bool Q_Exec( const char *cmd, char *cmdline, const char *, bool, bool waitfor ){
return true;
break;
case 0:
// XXX : if we run q3map2 with '-connect' - redirect stdout and stderr
// to /dev/null - aka build monitoring - as it's already going to
// be written to stdout via 'radiant/console.cpp → Sys_print
if ( cmdline != NULL && ( strstr( cmdline, "q3map2" ) != NULL ) && ( strstr( cmdline, "-connect" ) != NULL ) ) {
int devNullFd = open( "/dev/null", 0 );
if ( devNullFd != -1 ) {
dup2( devNullFd, 1 );
dup2( devNullFd, 2 );
}
}

// always concat the command on linux
if ( cmd ) {
strcpy( fullcmd, cmd );
Expand Down Expand Up @@ -139,4 +153,4 @@ bool Q_mkdir( const char* path ){
std::error_code err;
std::filesystem::create_directories( path, err );
return !err;
}
}

2 comments on commit 3d41d8f

@Aciz
Copy link
Contributor

@Aciz Aciz commented on 3d41d8f Oct 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hate to nag but this is not great either. Now you no longer get a proper, real-time output of q3map2 either, instead you only get the buffered radiant console output, which updates very rarely, and most of the time you have no real idea on how your compile is progressing.

Disabling build process monitoring gets around this sure, but then you loose the ability to detect leaks, and run engine after compile.

@Garux
Copy link
Owner Author

@Garux Garux commented on 3d41d8f Nov 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#221 improves situation in general.

Please sign in to comment.