Fork thread, Assertion failed. X11.

Hi all.
I wrote a program with the Motif Widget Toolkit. It has a
button and a scrollbar. When the user hits the button the
callback creates a new fork() thread. The new thread sleeps
for a while and then changes the position of the scrollbar.
It does this in an endless loop.

I need the fork thread because part of application must
go back to the event loop, dispatch all events and run
the callbacks.

Well, when the new thread tries to modify the scrollbar I get

main: xcb_io.c:221: poll_for_event: Assertion `(((long) (event_sequence) - (long) (dpy->request)) <= 0)' failed.

It works well if the scrollbar is modified inside the
original thread, but I get this error if I create the new
thread.

The code is posted here. C | #include <Xm/Xm.h> #include <Xm/XmAll.h> #incl - Main.c

Can anyone help? Thanks!

That's no thread. fork() creates a completely new process, with duplicates of all memory and open files therein. It doesn't even share your variables -- modify a variable in one, it won't be reflected in the other.

Try creating an actual thread-thread. See man pthread_create.

Thanks so much, Corona. Now all works fine! :slight_smile: