I have been using SDL for a couple of years now, both for development
under Linux on X86 and production on a Linux based arm RISC cpu (Arcom
Viper PXA255 based single board computer).
Yesterday I happened upon a problem whereby my app would hang. I traced
it to the particular combination of running SDL, on the arm CPU, and
calling the system call popen(). Other combinations such as no-SDL +
arm + popen() or SDL + x86 + popen() worked fine.
Normally when the app is running on the arm machine, the process is
visible thus (using ps-ef, process is called ‘t’):
377 root 1204 S /mnt/eas/src/eas/t
381 root 1204 S /mnt/eas/src/eas/t
382 root 1204 S /mnt/eas/src/eas/t
However when the app calls popen(), the result is as follows:
377 root 1236 D /mnt/eas/src/eas/t
381 root Z [t]
394 root 1236 S /mnt/eas/src/eas/t
The process is locked up and I have to kill -9 to get it back.
I was running SDL 1.2.7 but have upgraded to 1.2.9 and am experiencing
the same problem. I also looked through the SDL archives, Googled etc.
but to no avail.
To narrow it down I have produced a simple test program that exhibits
the fault. Maybe someone has an idea of what’s wrong. I suspect my
code is probably OK, though if it’s just my code at fault I’ll be very
happy! I’ll list it below as it’s quite short.
As I say, it’s just when running SDL on the Viper, and then calling popen().
#include <SDL.h> /* All SDL App’s need this */
/* Compile with:
arm-linux-gcc -o t t.c -I /usr/local/include/SDL
fprintf(stderr, “Could not initialize SDL: %s.\n”,
/* Clean up on exit */
/* Request a video mode */
if ((s = SDL_SetVideoMode(640, 480, 8, 0)) == NULL)
fprintf(stderr, “Couldn’t set video mode: %s\n”, SDL_GetError());
char *command = “uptime”;
if ((screen = display_init()) == NULL)
printf(“About to call popen() and hence lock up…\n”);
if ((fp = popen(command, “r”)) == NULL)
fprintf(stderr, “Problem calling popen()!\n”);
printf(“Oh, popen() returned!\n”);
R A Ward Ltd.
Christchurch, New Zealand