A question about terminal control in Python...
This is a wrapper program that uses the xmp binary to play mod files at random. However, I would like to have another process running so that if a good song is playing I can write the name of the filename to a file for future reference.
Code:
#!/usr/bin/python At the point where the os.fork() occurs, do both processes have stdin, stdout, and stderr all tied to the pty I am in? When it is forked, I understand that the child has an exact copy of all the file descriptors which should include stdin, stdout, and stderr that are similar to those of the parent. I think I need to be using the termios module. However, the documentation for the Python termios module is slim to none. It is also a little hard to grasp. Could somebody give me an example of how I would use that module in my specific case? |
I have no experience with Python forking, but right after the fork, both processes share the same pty. So to debug, write this piece in your code:
Code:
pid = os.fork(); Once you see this, it is easier to take it from there. jlinkels |
Ah ok thank you. Turns out I just needed to flush stdout continuously so that the output of the xmp process that the child ran continues to go to the screen.
|
I got what I was looking for.
1. Continuously flush stdout so that the output of the child process can continuously be outputted to the terminal. 2. non-blocking console input so that I can add a filename of a song to a favorites file. Code:
def isData(): |
All times are GMT -5. The time now is 12:05 PM. |