2022-11-20 05:43:00 +03:00
|
|
|
#if defined(HAVE_CONFIG_H)
|
|
|
|
#include "config_ac.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "log.h"
|
|
|
|
#include "os_calls.h"
|
|
|
|
#include "string_calls.h"
|
|
|
|
#include "xwait.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
int
|
|
|
|
wait_for_xserver(int display)
|
|
|
|
{
|
|
|
|
FILE *dp = NULL;
|
|
|
|
int ret = 0;
|
|
|
|
char buffer[100];
|
|
|
|
char exe_cmd[262];
|
|
|
|
|
|
|
|
LOG(LOG_LEVEL_DEBUG, "Waiting for X server to start on display %d", display);
|
|
|
|
|
2023-03-09 13:35:44 +03:00
|
|
|
g_snprintf(exe_cmd, sizeof(exe_cmd), "%s/waitforx", XRDP_LIBEXEC_PATH);
|
2022-11-20 05:43:00 +03:00
|
|
|
dp = popen(exe_cmd, "r");
|
|
|
|
if (dp == NULL)
|
|
|
|
{
|
2023-03-09 13:35:44 +03:00
|
|
|
LOG(LOG_LEVEL_ERROR, "Unable to launch waitforx");
|
2022-11-20 05:43:00 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (fgets(buffer, 100, dp))
|
|
|
|
{
|
|
|
|
g_strtrim(buffer, 2);
|
|
|
|
LOG(LOG_LEVEL_DEBUG, "%s", buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = pclose(dp);
|
|
|
|
if (ret != 0)
|
|
|
|
{
|
2023-03-09 13:35:44 +03:00
|
|
|
LOG(LOG_LEVEL_ERROR, "An error occurred while running waitforx");
|
2022-11-20 05:43:00 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|