Tue, 09 Jun 2009
Merging file descriptor output
I have a problem that I believe will be easy for someone with a bit of UNIX coding knowledge to solve, so I appeal to those that can to help.
I'm trying to write a DBus service that will spawn a command, and provide the output to the user. The service runs on the system bus as root, and so it is a form of privilege escalation. However, the command may be long running, and produce a lot of output as it works, so I want to allow the calling process to get this output before the command completes.
My current approach uses gobject.spawn_async and so gets file descriptors back, one for stdout and one for stderr. I currently have a thread that uses select to wait for output, and then uses DBus signals to allow the client to access it. This works great, except that stdout and stderr can become interleaved in the middle of lines.
I believe that I can't just wait for full lines before signalling, as a command might do something like print "Username: " and then wait for input. I could normally do full lines, and then if the child blocks on stdin send whatever it has written so far, but that doesn't seem ideal. (I haven't implemented anything about proving input on stdin so far, but I don't want a solution that makes it difficult to do so).
It seems to me that this is something that will be implemented somewhere, for instance my shell can run commands and then interleave the output in a desirable manner, but I haven't found how yet. Any suggestions are welcome, but this is from python, so system calls that I can't make directly from python would be a pain, though I'm not that bothered about portability.
Sun, 07 Jun 2009
Free Music
I came across Anthony Raijekov the other day, and was treated to some of his Trip-Hop, which is outstanding. That was an added bonus though, as I sought him out to download his Piano track: "Photo Theme: Window Like". You can find him on Jamendo and on ccmixter. I would highly recommending going to listen, and donating via Jamendo if you like what you hear.
This also led me to go back and listen to some new stuff from Amether, who I found a few years ago thanks to Rob Da Bank. Definitely worth checking out, especially their remix of "Artisan - Hold my breath".
On the freely available, if not freely licensed side I noticed a new station from the excellent SomaFM today: Lush. It is said to be "Sensuous and mellow vocals, mostly female, with an electronic influence," and so far I am enjoying it though it is rather similar to Groove Salad. I find that I can't keep SomaFM on all day every day while working though, as I find that it repeats tracks just a little too often.
I've also been listening a lot to Ombilikal which covers the harder edge very well, with some breaks, drum and bass, and dubstep amongst other things.
While in Barcelona I had the pleasure of meeting Karl Fogel (and hearing him play, which was a treat), and talking a bit about free content. He explained to me some of the things that they are trying to do with QuestionCopyright.org, and some of their methods. It's great to see more projects working on the issue in a very constructive manner, and I hope that they succeed. So that we can have many more artists like Anthony Raijekov that I can discover and reward for their work more directly.