Difference between revisions of "Starting Other Programs (KDE3 Architecture)"
imported>Eliddell (Created page with "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....") |
m (-Applicable to TDE (redundant)) |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
− | In |
+ | In TDE there are several ways to '''start other programs''' from within |
your application. Here is a short summary of your options with reasons why |
your application. Here is a short summary of your options with reasons why |
||
you should or should not use them. |
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. |
|
+ | = TDEProcess = |
||
− | ;KProcess |
||
− | + | You want to use [http://trinitydesktop.org/docs/trinity/tdelibs/tdecore/html/classTDEProcess.html TDEProcess] 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 Trinity 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 TDEProcess. Unlike TDEProcess, the [http://trinitydesktop.org/docs/trinity/tdelibs/tdecore/html/classKProcIO.html KProcIO] class actually makes it easy to send data to and receive data from the process. |
|
− | + | = startServiceByDesktopPath = |
|
− | + | Preferred way to launch desktop (Trinity/KDE/Gnome/X) applications or Trinity services. The application/service must have a .desktop file. It will make use of <tt>tdeinit</tt> for increased startup performance and lower memory usage. These benefits only apply to applications available as <tt>tdeinit</tt> loadable module. |
|
− | + | = KRun = |
|
− | + | Generic way to open documents/applications/shell commands. Uses <tt>startServiceBy....</tt> where applicable. Offers the additional benefit of startup-notification.<br/> [http://trinitydesktop.org/docs/trinity/tdelibs/tdeio/tdeio/html/classKRun.html 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 Trinity. |
|
Latest revision as of 16:37, 21 April 2022
In TDE 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.
TDEProcess
You want to use TDEProcess 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 Trinity applications. If you need to send/receive text like data to/from the process, you are probably better off with KProcIO.
KProcIO
Like TDEProcess. Unlike TDEProcess, the KProcIO class actually makes it easy to send data to and receive data from the process.
startServiceByDesktopPath
Preferred way to launch desktop (Trinity/KDE/Gnome/X) applications or Trinity services. The application/service must have a .desktop file. It will make use of tdeinit for increased startup performance and lower memory usage. These benefits only apply to applications available as tdeinit loadable module.
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 Trinity.
Initial Author: Waldo Bastian