On an FC5 box running 2.6.9-34.ELsmp with xorg 7.0.0/1.0.1 rpms, I'm
having an issue getting output from an Xvfb session started with
something like -

Xvfb :2 -screen 0 640x480x16 -ac -shmem &
xclock &

Dumping root window to a file with xwd or IM's import works. I can see
the root window and the xclock window.

I need to include this type of functionality in another program, so to
start with i wrote a simple program that would grab the xwd format
content from shmem which is "meant" to be written by Xvfb and output it
to a file, which in essence does the following operations:

shmptr = shmat( shmid, (void *)0, SHM_RDONLY ); /* attach to shmem */
int ctlrv = shmctl (shmid, IPC_STAT, &shmbuffer); /* get buffer info */
printf ("Buffer Size: %d\n", shmbuffer.shm_segsz);
printf ("Buffer Attach Time: %s", ctime(&shmbuffer.shm_atime));
printf ("Buffer Change Time: %s", ctime(&shmbuffer.shm_ctime));
fd = open(argv[2], O_WRONLY | O_CREAT, mode);
write (fd, shmptr, shmbuffer.shm_segsz);

When i try and view this, all i see is an empty root window! I'm
wondering if Xvfb is updating the shmem at all because looking at the
output of this program:

../shm2xwd 3309583 x.xwd
Buffer Size: 615328
Buffer Attach Time: Wed Sep 27 01:10:00 2006
Buffer Change Time: Tue Sep 26 17:27:25 2006

I see that the buffer change time was when i first started the Xvfb,
but it hasn't been updated since - i.e. when i started/restarted
xclock. Am i doing anything wrong or is this a bug, anyone have any
experiences to share?

The second part of my question relates to buffer updates (once the
first part is working) - how do i know when the buffer has been updated
(if the answer to first question is not related to buffer change time)?

Thanks, your help is greatly appreciated