On 2023-09-08, Sebastien Marie wrote: > "rpath" is a bit odd in xeyes(1) normal behaviour (but it will be required on > X11 error, as if I remember well, error codes are "translated" to message by > reading some file).
Exactly. X11 reads the error database `/usr/X11R6/share/X11/XErrorDB` if it needs to issue an error. However, we can force xeyes(1) to read the error database into memory at initialization before pledging; so if an error occurs, it would not need to read the database again. Quoting from `xenocara/app/xclock/xclock.c`: > { > /* force reading of XErrorDB into memory to avoid adding "rpath" to > pledge below */ > char buf[1]; > > (void)XGetErrorDatabaseText(XtDisplay(toplevel), "XProtoError", "0", "", > buf, 1); > } > if (pledge("stdio", NULL) == -1) > err(1, "pledge"); XGetErrorDatabaseText uses a static variable to hold the database. This variable is initialized in the first call, and then used by the following calls. On 2023-09-08, Sebastien Marie wrote: > For me, you are pledging too early (before initialization). It should be done > at > least after calling XtAppInitialize(3). > > It will be the main limitation for a tool like `abstain`. pledge(2) should be > called *after* initialization, and not at the beginning of the program. I also think that. If we pledge(2) after initializing the connection to the X Server, we can drop the "unix" and "inet" promises. Lucas de Sena