pid = strtoul(prs.name, &s, 10); if (!prs.name[0] || errno || *s)
if ((t = strchr(prs.name, '(')) == NULL) t = prs.name; else t++; pid = strtoul(t, &s, 10); if (!prs.name[0] || errno || (*s && (t == prs.name || *s != ')')))
remove_stale_rulesets(void){	struct pfioc_ruleset	 prs;	const int		 action[PF_RULESET_MAX] = { PF_SCRUB,				    PF_PASS, PF_NAT, PF_BINAT, PF_RDR };	u_int32_t		 nr, mnr;	memset(&prs, 0, sizeof(prs));	strlcpy(prs.anchor, anchorname, sizeof(prs.anchor));	if (ioctl(dev, DIOCGETRULESETS, &prs)) {		if (errno == EINVAL)			return (0);		else			return (1);	}	mnr = prs.nr;	nr = 0;	while (nr < mnr) {		char	*s;		pid_t	 pid;		prs.nr = nr;		if (ioctl(dev, DIOCGETRULESET, &prs))			return (1);		errno = 0;		pid = strtoul(prs.name, &s, 10);		if (!prs.name[0] || errno || *s)			return (1);		if (kill(pid, 0) && errno != EPERM) {			int i;			for (i = 0; i < PF_RULESET_MAX; ++i) {				struct pfioc_rule pr;				memset(&pr, 0, sizeof(pr));				memcpy(pr.anchor, prs.anchor, sizeof(pr.anchor));				memcpy(pr.ruleset, prs.name, sizeof(pr.ruleset));				pr.rule.action = action[i];				if ((ioctl(dev, DIOCBEGINRULES, &pr) ||				    ioctl(dev, DIOCCOMMITRULES, &pr)) &&				    errno != EINVAL)					return (1);			}			mnr--;		} else			nr++;	}	return (0);}