allow usage of --screen-blank --capture-raw-fb=/dev/null
This commit is contained in:
parent
3586a776a4
commit
6340351c3b
2 changed files with 18 additions and 4 deletions
|
@ -27,7 +27,6 @@ static inline int clone_fd(pid_t pid, int target_fd) {
|
|||
}
|
||||
|
||||
static inline int cmp_fds(pid_t pid, const char *drm_pth) {
|
||||
if (pid == 1) return -1;
|
||||
char path[PATH_MAX+1];
|
||||
snprintf(path, PATH_MAX+1, "/proc/%d/fd", pid);
|
||||
|
||||
|
@ -48,9 +47,9 @@ static inline int cmp_fds(pid_t pid, const char *drm_pth) {
|
|||
int cloned = clone_fd(pid, fd);
|
||||
if (cloned > 0 && drmIsMaster(cloned)) {
|
||||
ret = cloned;
|
||||
//if (kmsvnc->debug_enabled) {
|
||||
if (kmsvnc->debug_enabled) {
|
||||
fprintf(stderr, "found drm master pid=%d, fd=%d, cloned=%d\n", pid, fd, cloned);
|
||||
//}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (cloned > 0) close(cloned);
|
||||
|
@ -76,7 +75,7 @@ int drm_get_master_fd() {
|
|||
int count = scandir("/proc", &proclist, NULL, versionsort);
|
||||
int ret = -1;
|
||||
if (count >= 0) {
|
||||
for (int n = count - 1; n > 0; n--) {
|
||||
for (int n = 0; n < count; n++) {
|
||||
if (ret == -1 && proclist[n]->d_type == DT_DIR) {
|
||||
pid_t pid = (pid_t)atoi(proclist[n]->d_name);
|
||||
if (pid > 0) {
|
||||
|
|
15
kmsvnc.c
15
kmsvnc.c
|
@ -208,6 +208,7 @@ static void cleanup() {
|
|||
}
|
||||
}
|
||||
|
||||
void signal_handler_noop(int signum){}
|
||||
void signal_handler(int signum){
|
||||
if (kmsvnc->shutdown) {
|
||||
return;
|
||||
|
@ -437,6 +438,20 @@ int main(int argc, char **argv)
|
|||
else {
|
||||
fprintf(stderr, "open file %s failed, %s\n", kmsvnc->debug_capture_fb, strerror(errno));
|
||||
}
|
||||
if (kmsvnc->screen_blank) {
|
||||
sigset_t signal_set;
|
||||
int sig;
|
||||
sigemptyset(&signal_set);
|
||||
signal(SIGHUP, &signal_handler_noop);
|
||||
signal(SIGINT, &signal_handler_noop);
|
||||
signal(SIGTERM, &signal_handler_noop);
|
||||
sigaddset(&signal_set, SIGHUP);
|
||||
sigaddset(&signal_set, SIGINT);
|
||||
sigaddset(&signal_set, SIGTERM);
|
||||
fprintf(stderr, "blanking screen...\n");
|
||||
sigwait(&signal_set, &sig);
|
||||
fprintf(stderr, "got sig %d\n", sig);
|
||||
}
|
||||
cleanup();
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue