WXConsoleSpawner: Spawn console, when needed under GNU/Linux in GUI

All off topic discussions go here. Everything from the funny thing your cat did to your favorite tv shows. Non-programming computer questions are ok too.
Post Reply
nintyfan
Member
Member
Posts: 34
Joined: Wed Nov 07, 2018 10:15 am

WXConsoleSpawner: Spawn console, when needed under GNU/Linux in GUI

Post by nintyfan »

WXConsole spawner is mine project to spawn terminal, when process seems to be console application. Somebody asks me if there is list of console programs or programs were relaunch. Answer is not. We create special character device using CUSE/FUSE. When application read from that device or call poll on this device or do some other thinks, we asks to open console. When user decide to do so, we create konsole process with order to run WXConsoleSpawner_console_server and pass some fd number via command line arguments. This WXConsoleSpawner_console_server process works as proxy - events from console are redirected to WXConsoleSpawner process and events from WXConsoleSpawner process (so from program we are running) are redirected to our proxy.

We replay data wrote to stdout/stderr, once we spawn terminal, so no output was lost.

We also use special library, loaded using LD_PRELOAD, so it not working with sudo yet. I was trying

Many thinks works. We can ran browsh, but only run currently. Programs like bash do not shown prompt, which works previously. Dialog do not respond on winsch signal. Also running some programs in bash and pressing ctrl+c sends INT signal to each process, so bash closes also.

I am searching for help with some of my projects.

Here is link:
https://sourceforge.net/projects/wxconsolespawner/
nullplan
Member
Member
Posts: 2033
Joined: Wed Aug 30, 2017 8:24 am

Re: WXConsoleSpawner: Spawn console, when needed under GNU/Linux in GUI

Post by nullplan »

nintyfan wrote: Sun Apr 05, 2026 9:14 am WXConsole spawner is mine project to spawn terminal, when process seems to be console application. Somebody asks me if there is list of console programs or programs were relaunch. Answer is not. We create special character device using CUSE/FUSE. When application read from that device or call poll on this device or do some other thinks, we asks to open console. When user decide to do so, we create konsole process with order to run WXConsoleSpawner_console_server and pass some fd number via command line arguments. This WXConsoleSpawner_console_server process works as proxy - events from console are redirected to WXConsoleSpawner process and events from WXConsoleSpawner process (so from program we are running) are redirected to our proxy.
Seems overcomplicated to me. Why not "just" implement or mod a terminal emulator to not show the window until the first I/O happens on the slave side? And this will still catch GUI applications that send debug text to the console.
Carpe diem!
nintyfan
Member
Member
Posts: 34
Joined: Wed Nov 07, 2018 10:15 am

Re: WXConsoleSpawner: Spawn console, when needed under GNU/Linux in GUI

Post by nintyfan »

I test many way to solve this problem. Console emulator is not sufficient, because it cannot test for poll. Some tolls do not simple read from terminal, because it waits for many events (from different sources), so it does poll/select. My approach allows to handle this. Another approach is settings/read some ioctl. With terminal emulator we cannot handle this.

Current solution also wrote logs in some place and redirect it to server, when terminal was spawn.

We cannot catch write operation, because GUI applications maybe send some stuff to logs, but do not need to spawn console window. Many GUI applications logs many operations and user would not see these logs.
nintyfan
Member
Member
Posts: 34
Joined: Wed Nov 07, 2018 10:15 am

Re: WXConsoleSpawner: Spawn console, when needed under GNU/Linux in GUI

Post by nintyfan »

Currently dialog and nvidia driver installer correctly responds for signal telling window size was changed. I have many problems still:
1. Sudo telling that it was not ran under terminal (I will try to repair this by creating FUSE FS layer, which results correct data for getattr, when context == NULL and pretend to be terminal device, when context != NULL; maybe this will help)
2. Pressing arrows to not generate any actions (I must look how getchar works; I look at termios and there is not any max_character_count, but maybe canonical mode broke things).
3. Bash do not shown prompt
4. Sending signals sends signal to each process, who reads from terminal

I think I can repair those bugs, but any help are welcome.
nintyfan
Member
Member
Posts: 34
Joined: Wed Nov 07, 2018 10:15 am

Re: WXConsoleSpawner: Spawn console, when needed under GNU/Linux in GUI

Post by nintyfan »

Many things related to WXConsoleSpawner now works. Even dialog program. I look at it and do not see problems. Nvidia GPU installer starts, but I do not have NVidia GPU on my VM, so untested. It also looks good. You can change terminal window size, use keyboard. Dialog also allow to use mouse. SUDO works, if you ran some helper, but this helper makes many things on your system do not work - even sudo if not ran inside WXConsoleSpawner. Bash seems look too. Tomorrow, I will clean up code and try to eliminate some problems. WXConsoleSpawner mount --bind /dev/pts/X, but do not umount. I will repair this in near future.
nintyfan
Member
Member
Posts: 34
Joined: Wed Nov 07, 2018 10:15 am

Re: WXConsoleSpawner: Spawn console, when needed under GNU/Linux in GUI

Post by nintyfan »

nullplan wrote: Sun Apr 05, 2026 12:29 pm
nintyfan wrote: Sun Apr 05, 2026 9:14 am WXConsole spawner is mine project to spawn terminal, when process seems to be console application. Somebody asks me if there is list of console programs or programs were relaunch. Answer is not. We create special character device using CUSE/FUSE. When application read from that device or call poll on this device or do some other thinks, we asks to open console. When user decide to do so, we create konsole process with order to run WXConsoleSpawner_console_server and pass some fd number via command line arguments. This WXConsoleSpawner_console_server process works as proxy - events from console are redirected to WXConsoleSpawner process and events from WXConsoleSpawner process (so from program we are running) are redirected to our proxy.
Seems overcomplicated to me. Why not "just" implement or mod a terminal emulator to not show the window until the first I/O happens on the slave side? And this will still catch GUI applications that send debug text to the console.
Done as you said. But this requires me to write bpf filters, so it made me though a little complicated. I try to do this previously, but there no support for ebpf in gcc. Actually it is, but it is not too good. I must use llvm. Previously I wrote ebpf assembler instructions inside C code and I cannot done it. And I was trying to add this to KDE/Plasma project, so telling developers to add llvm would not be nice. Currently, I am using llvm to eBPF stuff, so I am not sure how add support to Plasma/GNOME/etc.
I modify Konsole, but I clone subprojects and must ensure how to publish my work.

Anyway, thanks!
nintyfan
Member
Member
Posts: 34
Joined: Wed Nov 07, 2018 10:15 am

Re: WXConsoleSpawner: Spawn console, when needed under GNU/Linux in GUI

Post by nintyfan »

Newest version was published on sourceforge.net (https://sourceforge.net/projects/wxcons ... files/RPM/ ; https://sourceforge.net/projects/wxconsolespawner ). It works only on Plasma6 and only if you right-click on executable, select run with ... and ran with WXConsoleSpawner. KIO integration does not exist and probably never will. I will prepare my own version of KIO, which you must install instead of normal KIO, so write cat /etc/hosts and run this command via krunner should be possible.

Video for normal users: https://youtu.be/R4oD74QQytI
Post Reply