Hi,
My program creates and starts a thread, then invokes a system()
function call to launch a system command ("ls" for instance). The
program seems to never come back from the system call (whatever the
called function being passed as argument). Issuing a system call
without creating the thread works fine, as well as creating the
thread without issuing a systeme call, but both together fail.
This is a very weird behavior, I obvioulsy do not encounter this
issue under regular linux distribution (I checked to be sure).
For a small example, report at c file below .
I would appreciate your help regarding that issue.
TIA.
----------
AXIS_USABLE_LIBS = UCLIBC GLIBC
include $(AXIS_TOP_DIR)/tools/build/Rules.axis
PROGS = main
LIB_RT = ${AXIS_TOP_DIR}/apps/fox_satet/
INSTDIR = $(prefix)/mnt/flash/
INSTMODE = 0755
INSTOWNER = root
INSTGROUP = root
OBJS = main.o
OPTIONS = -static
CFLAGS += -I${LIB_RT}
LDFLAGS += -pthread -D_REENTRANT
all: $(PROGS)
$(PROGS): $(OBJS)
$(CXX) $(LDFLAGS) $(OPTIONS) $^ $(LDLIBS) -o $@
cris-strip --strip-unneeded main
install: $(PROGS)
$(INSTALL) -d $(INSTDIR)
$(INSTALL) -m $(INSTMODE) -o $(INSTOWNER) -g $(INSTGROUP)
$(PROGS) $(INSTDIR)
clean:
rm -f $(LIB_RT)*.o
rm -f $(PROGS) *.o core
and c file
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>
void *func_thread(void * arg);
int main(int argc, char *argv[])
{
pthread_t m_thread;
pthread_attr_t m_attr_thread;
int m_error;
printf("Start\n");
pthread_attr_init(&m_attr_thread);
m_error = pthread_create(&m_thread, &m_attr_thread,
func_thread, NULL);
system("ls");
printf("LS do !\n");
pthread_join(m_thread, NULL);
printf("End\n");
return(0);
}
/*-----------------------------------------*/
void *func_thread(void * arg)
{
sleep(5);
}
/*-----------------------------------------*/