PDA

View Full Version : reading from the command line for a certain time - depending on system workload



urwald
28th February 2009, 23:18
Hello.

I'm writing a KDE frontend for a command line tool (streamripper). Each time when the frontend starts, it should check the version number of the command line tool. The question is how do I realize this call?

Normally, calling the command line tool with the parameter "-v" returns immediatly the version number, so in this case there is no problem.

However, the user can change the command - and maybe he could enter a wrong command (think of "mc" or other strange things). So I want to make sure that in such a case, the execution of the command line tool is aborted after (for example) 1 second. (The time must be short because the GUI should stay responsive.)

While 1 second is normally enough, this might be a problem when at this moment the system load is very hight. The frontend would think that the command line tool isn't working well and would terminate. (On the other hand, I don't want to wait for example 30 second, because in this case, users would _always_ be forced to wait 30 seconds until the recognization of the command line tool terminates.)

Is there a possibility to abort the command line tool not after a fixed time of 1 second, but maybe after a certain number of processor cycles that the specified process has run? Or is there another solution to the problem?

(It would be great if this solution works patform-independent/qt-only, without using system libraries.)