Ive solved my problem. The thing is that i was executing code after the fork() call with out doing any exec() (in particular, db2 cli api calls). That caused problems with the threads that are embedded in the db2 library. According to the linux documentation, its not advisable to do a fork() without an exec() when using multithreading libraries (basically, the status variables of the mulitithreaded library are inconsistent in the child thread, this includes mutex variable that the library might have created). So now I changed to to an exec() asap after the fork() calling a complete new program.
frusconi, thanks for your reply. but as far as im concerned, db2 cli DOES support mulitthreading by default (say, it initializes different contexts so api calls are thread-safe).