Communicating between two threads

You could have a BlockingQueue of message objects. Other threads would place messages onto the queue. As part of the while(true) loop, thread A would poll the queue and process any messages that have arrived. In code: class A extends Thread{ List<Object> objs = something ;//init it BlockingQueue<Message> queue = new LinkedBlockingQueue<Message>(); void run(){ while(true){ … Read more

Capture “Segmentation fault” message for a crashed subprocess: no out and err after a call to communicate()

“Segmentation fault” message might be generated by a shell. To find out, whether the process is kill by SIGSEGV, check proc.returncode == -signal.SIGSEGV. If you want to see the message, you could run the command in the shell: #!/usr/bin/env python from subprocess import Popen, PIPE proc = Popen(shell_command, shell=True, stdout=PIPE, stderr=PIPE) out, err = proc.communicate() … Read more