core
core copied to clipboard
Fixes: CFE-3982 do not kill unrelated process
Pull request to fix https://tracker.mender.io/browse/CFE-3982
About the coding style, is there anything else than the function name that you want to point me to ?
About the coding style, is there anything else than the function name that you want to point me to ?
@peckpeck Some things I see at first glance:
- Space after if, commas, and around operators (like
>
). - Opening curly brace on separate line (
{
). - Don't do
if
's without curly braces. - Avoid unnecessary typecasts.
- Pointer asterisk to the right, next to the name (
FILE *f
). - Compare pointers to
NULL
explicitly (if (f != NULL)
).
sorry for the delay
@vpodzime any news on this ?
Hi @peckpeck ! as far as i know, Windows is not the only platform without the /proc
file. Please correct me if I'm wrong. In libpromises/process_select.h
we have some functions for querying processes. Maybe you can use those? E.g.
ClearProcessTable(); /* Make sure old process table is not cached */
Item *procs = NULL;
if (LoadProcessTable())
{
ProcessSelect ps = PROCESS_SELECT_INIT;
ps.max_pid = ps.min_pid = lock_data.pid;
procs = SelectProcesses("cf-.*", &ps, true);
}
if (procs == NULL)
{
/* Process select returned nothing, it must be an unrelated process */
return false;
}
DeleteItemList(procs);
return true;
Not sure if this would work, but feel free to give it a try. Otherwise you could maybe guard it with the #ifdef __linux__
macro.
PR updated, sorry for the delay
@peckpeck I took your code as a base for my work on the related ticket. Thank you for your contribution!