You are not logged in.
hi, im new to xcb and xorg development, so I've been trying to figure why the x server disconnects once I try to spawn dmenu (not sure ifs dmenu specific or not), I copy pasted that snippet from another wm, so that's why I don't know how can I debug or anything. It's also my first time to write a wm, so sorry if my mistake looks silly.
here's my code
static void spawn(char **com) {
if (fork() == 0) {
setsid();
if (fork() != 0) {
_exit(0);
}
execvp((char *)com[0], (char **)com);
_exit(0);
}
wait(NULL);
}
^ And that's the function used to spawn dmenu (https://github.com/bwkam/rwm/blob/6e266 … /rwm.c#L17)
Thanks in advance
Last edited by rynite (2023-02-15 18:16:59)
Offline
Can you start *any* gui program in any way? What makes you think it's the spawn function and not the map request handler?
Note that one would generally close the display connection and any other high-number file descriptors under the first fork of a spawn function, but I doubt failing to do so would cause the kind of problem you describe.
Also I only really know Xlib and never bothered with XCB, but are you supposed to "free" the ev pointer returned from xcb_wait_for_event? That seems odd to me (and sadly the documentation doesn't specify ownership of the pointer either way).
Last edited by Trilby (2023-02-15 17:11:38)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
thanks for the reply, well, is there a way I can launch it other than using spawn()?
I have tried setting DISPLAY on a different TTY to :3. and running for example,
DISPLAY=:3 kitty
(on a different TTY) after connecting to the X server, but they all fail to run at that display.
I don't know if it's the map request handler, I revised it and it looks good to me, mistakes are possible though since I'm really new to that.
Last edited by rynite (2023-02-15 17:14:35)
Offline
Launching kitty like that should work assuming your wm is in fact using DISPLAY=:3, but is it? Do you have 3 other X sessions running at the same time?
Also when you say the server disconnects, what exactly does that mean? Is it resulting in a seg fault?
EDIT: on on the comments on freeing 'ev', I'm not sure that line of code is ever even reachable. You have some odd extra curly braces that make that case statement a bit odd to read (individual case blocks do not need to be surrounded in braces). The free(ev) line is within the switch statement but outside of any case block (and the last case block does terminate with 'break') so I believe that is unreachable code that will never run.
Last edited by Trilby (2023-02-15 17:16:53)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Nope, just gdm and qtile, I'm using fish, so I did
set DISPLAY :3
, I even tried 8, but same output.
I'm not sure, but it just disconnects and I find nothing useful in the xorg log file.
[ 7223.823]
X.Org X Server 1.21.1.7
X Protocol Version 11, Revision 0
[ 7223.824] Current Operating System: Linux archlinux 6.1.10-arch1
-1 #1 SMP PREEMPT_DYNAMIC Mon, 06 Feb 2023 09:28:04 +0000 x86_64
[ 7223.824] Kernel command line: BOOT_IMAGE=/vmlinuz-linux root=UU
ID=f8e501a0-8911-4e98-a9e1-2c78078aa062 rw rootfstype=ext4 loglevel
=3 quiet
[ 7223.824]
[ 7223.824] Current version of pixman: 0.42.2
[ 7223.824] Before reporting problems, check http://wiki.x.org
to make sure that you have the latest version.
[ 7223.824] Markers: (--) probed, (**) from config file, (==) defa
ult setting,
(++) from command line, (!!) notice, (II) informational,
(WW) warning, (EE) error, (NI) not implemented, (??) unknow
n.
[ 7223.824] (==) Log file: "/home/ryn/.local/share/xorg/Xorg.1.log
", Time: Wed Feb 15 19:15:06 2023
[ 7223.824] (==) Using config directory: "/etc/X11/xorg.conf.d"
[ 7223.825] (==) Using system config directory "/usr/share/X11/xor
g.conf.d"
[ 7223.825] (==) No Layout section. Using the first Screen sectio
n.
[ 7223.825] (==) No screen section available. Using defaults.
[ 7223.825] (**) |-->Screen "Default Screen Section" (0)
[ 7223.825] (**) | |-->Monitor "<default monitor>"
[ 7223.825] (==) No monitor specified for screen "Default Screen S
ection".
Offline
EDIT: on on the comments on freeing 'ev', I'm not sure that line of code is ever even reachable. You have some odd extra curly braces that make that case statement a bit odd to read (individual case blocks do not need to be surrounded in braces). The free(ev) line is within the switch statement but outside of any case block (and the last case block does terminate with 'break') so I believe that is unreachable code that will never run.
Oh, I see that now, let me fix that real quick
Offline
You can't just chose random DISPLAY numbers. You need to set it to the DISPLAY that you rwm window manager is using (and if you don't specify otherwise, this would generally be the lowest number not currently in use). Don't check the xorg log for evidence of a seg fault - it wouldn't be there. Check the output of your wm ... or check `coredumptcl list`.
Last edited by Trilby (2023-02-15 17:24:31)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
You can't just chose random DISPLAY numbers. You need to set it to the DISPLAY that you rwm window manager is using (and if you don't specify otherwise, this would generally be the lowest number not currently in use). Don't check the xorg log for evidence of a seg fault - it wouldn't be there. Check the output of your wm ... or check `coredumptcl list`.
How can I find it, I tried to echo it, but I get nothing, and I don't specify any specific values for it in my code
And yeah, you're right, it was a segv
I checked `coredumpctl list`
Edit: It's only DISPLAY=:0 that works which is qtile (what I'm running at the moment)
Last edited by rynite (2023-02-15 17:41:03)
Offline
EDIT: on on the comments on freeing 'ev', I'm not sure that line of code is ever even reachable. You have some odd extra curly braces that make that case statement a bit odd to read (individual case blocks do not need to be surrounded in braces). The free(ev) line is within the switch statement but outside of any case block (and the last case block does terminate with 'break') so I believe that is unreachable code that will never run.
I'm suffering right now to find these extra braces, looks like the prettier neovim plugin made it look ugly like that, I'll use code next time.
May you help please?
Last edited by rynite (2023-02-15 17:51:29)
Offline
I found it out, I removed the asterisk at
https://github.com/bwkam/rwm/blob/9d118 … rwm.c#L122
and it worked, dmenu, kitty, ..etc, they all work
Thanks for helping!!
Offline
Ah, I missed that - that'd certainly do it as that'd be attempting to write to a random memory location not allotted to your code.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline