5 #include <lib/base/estring.h>
6 #include <enigma_processutils.h>
8 long *eProcessUtils::getPID(const char *procname
)
11 long *pidList
= (long *)malloc(sizeof(long));
15 char buf
[1024], cmdline
[40];
18 DIR *dir
= opendir("/proc");
23 if ((entry
= readdir(dir
)) == NULL
)
31 if (!(*name
>= '0' && *name
<= '9'))
35 sprintf(cmdline
, "/proc/%d/cmdline", pid
);
36 if ((fp
= fopen(cmdline
, "r")) == NULL
)
39 if ((fread(buf
, 1, sizeof(buf
) - 1, fp
)) > 0)
41 if (strstr(buf
, procname
) != 0)
43 pidList
= (long *)realloc( pidList
, sizeof(long) * (i
+ 2));
51 pidList
[i
] = (i
== 0) ? -1 : 0;
56 void killPID(long *pid
)
58 if (*pid
!= -1 && *pid
!= 0)
60 if (kill(*pid
, SIGTERM
)!= 0)
67 void eProcessUtils::killProcess(const char *procname
)
69 if(strlen(procname
) != 0)
72 pidList
= getPID(procname
);
77 for (pid
= pidList
; *pid
!= 0; pid
++)