lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Hi :)   

I have a question about the Lua source code.

I use lua library in Linux environment, but deadlock phenomenon, the following is part of the stack information:

Thread 4 (Thread 0x7f7ae26ec700 (LWP 14396)):
#0  0x00007f7b7ab03d1c in __lll_lock_wait_private () from /lib64/
#1  0x00007f7b7aa76640 in _L_lock_4452 () from /lib64/
#2  0x00007f7b7aa75a08 in _IO_flush_all_lockp () from /lib64/

Thread 181 (Thread 0x7f7b3af9d700 (LWP 14197)):
#0  0x00007f7b7ab03d1c in __lll_lock_wait_private () from /lib64/
#1  0x00007f7b7aa76728 in _L_lock_6097 () from /lib64/
#2  0x00007f7b7aa7647f in __GI__IO_list_lock () from /lib64/
#3  0x00007f7b7aabd087 in fork () from /lib64/

The problem lies in the use of the following macro:
#define l_popen(L,c,m) (fflush(NULL), popen(c,m))

It is fflush(NULL) that causes the deadlock. I can avoid this deadlock problem if I don't call fflush before popen.
So my question is:
1. Can I just remove fflush(NULL)? What are the risks?
2. If not, is there any other way to solve the problem?

Thank you! :)