mirror of
https://github.com/sheumann/hush.git
synced 2025-01-14 12:30:40 +00:00
Patch from Natanael Copa to make start-stop-daemon just use readlink and
strcmp to check if a program is already running.
This commit is contained in:
parent
adff40e80d
commit
8cedabaee0
@ -39,16 +39,17 @@ static inline void push(pid_t pid)
|
|||||||
|
|
||||||
static int pid_is_exec(pid_t pid, const char *name)
|
static int pid_is_exec(pid_t pid, const char *name)
|
||||||
{
|
{
|
||||||
char buf[32];
|
char buf[32], *execbuf;
|
||||||
struct stat sb, exec_stat;
|
int equal;
|
||||||
|
|
||||||
if (name)
|
|
||||||
xstat(name, &exec_stat);
|
|
||||||
|
|
||||||
sprintf(buf, "/proc/%d/exe", pid);
|
sprintf(buf, "/proc/%d/exe", pid);
|
||||||
if (stat(buf, &sb) != 0)
|
execbuf = xstrdup(name);
|
||||||
return 0;
|
readlink(buf, execbuf, strlen(name)+1);
|
||||||
return (sb.st_dev == exec_stat.st_dev && sb.st_ino == exec_stat.st_ino);
|
|
||||||
|
equal = ! strcmp(execbuf, name);
|
||||||
|
if (ENABLE_FEATURE_CLEAN_UP)
|
||||||
|
free(execbuf);
|
||||||
|
return equal;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pid_is_user(int pid, int uid)
|
static int pid_is_user(int pid, int uid)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user