Difference between revisions of "Development/Architecture/KDE3/Starting Other Programs"

Jump to: navigation, search
 

Latest revision as of 22:36, 11 March 2007

KDE Architecture - Starting programs

In KDE there are several ways to start other programs from within your application. Here is a short summary of your options with reasons why you should or should not use them.

fork + exec
You never want to use this unless you have a very good reason why it is impossible to use KProcess.
KProcess
You want to use KProcess class if you need to start a new process which needs to be a child of your process, e.g. because you want to catch stdout/stderr or need to send it data via stdin. You should never use this to start other KDE applications unless your application is called kgdb :-) If you need to send/receive text like data to/from the process, you are probably better off with KProcIO.
KProcIO
Like KProcess. Unlike KProcess, the KProcIO class actually makes it easy to send data to and receive data from the process.
startServiceByDesktopPath
Preferred way to launch desktop (KDE/Gnome/X) applications or KDE services. The application/service must have a .desktop file. It will make use of KDEinit for increased startup performance and lower memory usage. These benefits only apply to applications available as KDEinit loadable module (KLM).
KRun
Generic way to open documents/applications/shell commands. Uses startServiceBy.... where applicable. Offers the additional benefit of startup-notification.
KRun can start any application, from the binary or the desktop file, it will determine the mimetype of a file before running the preferred handler for it, and it can also start shell commands. This makes KRun the recommended way to run another program in KDE.


Initial Author: Waldo Bastian


This page was last modified on 11 March 2007, at 22:36. This page has been accessed 2,566 times. Content is available under Creative Commons License SA 3.0 as well as the GNU Free Documentation License 1.2.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V.Legal