<table><tr><td style="">davidedmundson added a comment.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D20007">View Revision</a></tr></table><br /><div><div><p>To give a context for people who haven't seen the prior conversation.</p>

<p>Right now kdevelop (optionally) pulls in libksysguard from plasma to show a simple process list, which isn't ideal. <br />
We're not technically API stable and we'll go to Qt6 at a different time.</p>

<p>A patch wants to add this in solid (and originally wanted to pull in libksysguard) which I've rejected because of the complicated dependency.</p>

<p>We also have 2 other uses in plasma that use libksysguard just to get the name of a PID.</p>

<p>I don't want to make libksysguard a framework as it's way too heavy for these usecases, it reads a billion /proc files populating a whole table full of stats and comes with a widgets dependency.</p>

<p>IMHO a simpler portable process list of PID + name will be useful</p></div></div><br /><div><strong>INLINE COMMENTS</strong><div><div style="margin: 6px 0 12px 0;"><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D20007#inline-112234">View Inline</a><span style="color: #4b4d51; font-weight: bold;">hallas</span> wrote in <span style="color: #4b4d51; font-weight: bold;">CMakeLists.txt:246</span></div>
<div style="margin: 8px 0; padding: 0 12px; color: #74777D;"><p style="padding: 0; margin: 8px;">Should util/kprocesslist.h also be added here?</p></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">yes</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D20007#inline-112235">View Inline</a><span style="color: #4b4d51; font-weight: bold;">hallas</span> wrote in <span style="color: #4b4d51; font-weight: bold;">kprocesslist.h:1</span></div>
<div style="margin: 8px 0; padding: 0 12px; color: #74777D;"><p style="padding: 0; margin: 8px;">Is this license ok?</p></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">I think so, someone who's into licenses probably should check</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D20007#inline-112236">View Inline</a><span style="color: #4b4d51; font-weight: bold;">hallas</span> wrote in <span style="color: #4b4d51; font-weight: bold;">kprocesslist.h:36</span></div>
<div style="margin: 8px 0; padding: 0 12px; color: #74777D;"><p style="padding: 0; margin: 8px;">I modified the interface slightly so that it fits better with other KDE APIs, I don't know what you guys think about it?</p></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Generally fine, I would put the method in a namespace</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D20007#inline-112255">View Inline</a><span style="color: #4b4d51; font-weight: bold;">kprocesslist.h:41</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"><span style="color: #74777d"> */</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"><span style="color: #aa4000">struct</span> <span class="n">KProcessInfo</span> <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">    <span style="color: #aa4000">unsigned</span> <span style="color: #aa4000">int</span> <span class="n">pid</span><span class="p">;</span> <span style="color: #74777d">///< The pid of the process</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">This isn't future proof.</p>

<p style="padding: 0; margin: 8px;">We probably need something with Pimpl (maybe a implicitly shared class)</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D20007#inline-112237">View Inline</a><span style="color: #4b4d51; font-weight: bold;">hallas</span> wrote in <span style="color: #4b4d51; font-weight: bold;">kprocesslist.h:42</span></div>
<div style="margin: 8px 0; padding: 0 12px; color: #74777D;"><p style="padding: 0; margin: 8px;">I changed the pid to be a unsigned int instead, since both Windows and Unix use a number as the pid</p></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Needs to be qint64 to cover windows</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D20007#inline-112239">View Inline</a><span style="color: #4b4d51; font-weight: bold;">hallas</span> wrote in <span style="color: #4b4d51; font-weight: bold;">kprocesslist.h:43</span></div>
<div style="margin: 8px 0; padding: 0 12px; color: #74777D;"><p style="padding: 0; margin: 8px;">What is the exact semantics of this field?</p></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Reading the code back this is:</p>

<p style="padding: 0; margin: 8px;">the full command line if available (full /proc/$pid/cmdline)<br />
 failing that the executable name (/proc/$pid/stat) <br />
 failing that the executable name (from ps)</p>

<p style="padding: 0; margin: 8px;">(I have no idea about windows)</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D20007#inline-112240">View Inline</a><span style="color: #4b4d51; font-weight: bold;">hallas</span> wrote in <span style="color: #4b4d51; font-weight: bold;">kprocesslist.h:45</span></div>
<div style="margin: 8px 0; padding: 0 12px; color: #74777D;"><p style="padding: 0; margin: 8px;">Do we really need this? Should we document all the valid states?</p></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Definitely needs some docs. An enum might be better when we figure out what we want.</p>

<p style="padding: 0; margin: 8px;">(or maybe just kill it?)</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D20007#inline-112242">View Inline</a><span style="color: #4b4d51; font-weight: bold;">hallas</span> wrote in <span style="color: #4b4d51; font-weight: bold;">kprocesslist.h:56</span></div>
<div style="margin: 8px 0; padding: 0 12px; color: #74777D;"><p style="padding: 0; margin: 8px;">Is this the interface we want?</p></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Based on the use cases I've seen I think we want:</p>

<p style="padding: 0; margin: 8px;">KProcessList GetProcessList(); <-- for the kdevelop etc case</p>

<p style="padding: 0; margin: 8px;">KProcess GetProcess(qint64 pid); <-- for the device manager / plasma vaults case</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D20007#inline-112243">View Inline</a><span style="color: #4b4d51; font-weight: bold;">hallas</span> wrote in <span style="color: #4b4d51; font-weight: bold;">kprocesslist.h:56</span></div>
<div style="margin: 8px 0; padding: 0 12px; color: #74777D;"><p style="padding: 0; margin: 8px;">I haven't written any tests for the code as I am not sure how I can do that in a portable and reproduceable way.</p></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">As for unit tests, maybe something like:</p>

<ul class="remarkup-list">
<li class="remarkup-list-item">spawn an app with qprocess</li>
<li class="remarkup-list-item">find it in the list</li>
</ul>

<p style="padding: 0; margin: 8px;">We'll know the PID from qprocess, we know our own user id, we know the name</p></div></div></div></div></div><br /><div><strong>REPOSITORY</strong><div><div>R244 KCoreAddons</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D20007">https://phabricator.kde.org/D20007</a></div></div><br /><div><strong>To: </strong>hallas, davidedmundson, broulik<br /><strong>Cc: </strong>kde-frameworks-devel, michaelh, ngraham, bruns<br /></div>