On 2016-12-14 at 22:59:25 +0100, Vadim Kochan <vadi...@gmail.com> wrote:
[...]
> +int proc_find_by_inode(ino_t ino, char *cmdline, size_t len, pid_t *pid)
> +{
> +     struct dirent *ent;
> +     DIR *dir;
> +
> +     if (ino <= 0) {
> +             cmdline[0] = '\0';
> +             return 0;
> +     }
> +
> +     dir = opendir("/proc");
> +     if (!dir)
> +             panic("Cannot open /proc: %s\n", strerror(errno));
> +
> +     while ((ent = readdir(dir))) {
> +             int ret;
> +             char *end;
> +             const char *name = ent->d_name;
> +             pid_t _pid = strtoul(name, &end, 10);
> +
> +             /* not a PID */
> +             if (_pid == 0 && end == name)
> +                     continue;
> +
> +             ret = __match_pid_by_inode(_pid, ino);
> +             if (!ret) {
> +                     ret = proc_get_cmdline(_pid, cmdline, len);
> +                     if (ret < 0)
> +                             panic("Failed to get process cmdline: %s\n", 
> strerror(errno));
> +
> +                     *pid = _pid;

closedir() is missing here.

> +                     return ret;
> +             }
> +     }
> +
> +     closedir(dir);
> +     return -1;
> +}
> +
>  int proc_exec(const char *proc, char *const argv[])
>  {
>       int status;

-- 
You received this message because you are subscribed to the Google Groups 
"netsniff-ng" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to netsniff-ng+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to