static int columns[ARRAY_SIZE(infos) * 2];
static size_t ncolumns;
-static pid_t pid = 0;
-
static struct libmnt_table *tab; /* /proc/self/mountinfo */
/* basic output flags */
}
}
-static int show_locks(struct list_head *locks)
+static int show_locks(struct list_head *locks, pid_t target_pid)
{
int rc = 0;
size_t i;
list_for_each(p, locks) {
struct lock *l = list_entry(p, struct lock, locks);
- if (pid && pid != l->pid)
+ if (target_pid && target_pid != l->pid)
continue;
add_scols_line(table, l, locks);
{ 0 }
};
int excl_st[ARRAY_SIZE(excl)] = UL_EXCL_STATUS_INIT;
+ pid_t target_pid = 0;
+
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
json = 1;
break;
case 'p':
- pid = strtos32_or_err(optarg, _("invalid PID argument"));
+ target_pid = strtos32_or_err(optarg, _("invalid PID argument"));
break;
case 'o':
outarg = optarg;
rc = get_local_locks(&locks);
if (!rc && !list_empty(&locks))
- rc = show_locks(&locks);
+ rc = show_locks(&locks, target_pid);
mnt_unref_table(tab);
return rc;