Even a compositor is unnecessary to fix screen tearing these days: https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests...
> The corrected standard C source code might look like this (still disregarding error handling and short writes):
>
> void
> write_string (int fd, const char \*s)
> {
> write (1, s, strlen (s));
> }
And disregarding the passed file descriptor! :) chdir("/"); /* go to / of "chroot jail" */
mkdir("foo", ...); /* create directory in jail */
chroot("foo"); /* change / to foo */
/* fail to chdir("foo"); */
chdir(".."); /* instead go up parent (there is nothing preventing you since you are no longer in the "chroot jail" since the jail is now foo and you never entered it) */
chdir("..");
/* ... */
chdir(".."); /* . is now the real root */
chroot("."); /* change / to the real root */
This is why the man pages for the linux system call rightfully put "chroot jail" in scare quotes. They are trivially escaped by a root user making basic linux system calls, and the man pages even sketch out how for you. Some operating systems attempt to provide more secure chroot jails, but linux chroot() does not provide this.