OpenVZ Forum


Home » Mailing lists » Devel » [PATCH 1/2] signal checkpoint: define /proc/pid/sig/
Re: [PATCH 1/2] signal checkpoint: define /proc/pid/sig/ [message #18904 is a reply to message #18865] Tue, 12 June 2007 16:30 Go to previous messageGo to previous message
Cedric Le Goater is currently offline  Cedric Le Goater
Messages: 443
Registered: February 2006
Senior Member
[ ... ]

>>> +static int print_sigpending_alloc(char **bufp, struct sigpending *pending)
>>> +{
>>> +	int alloced=0;
>>> +	char *buf, *p;
>>> +	struct sigqueue *q;
>>> +	struct siginfo *info;
>>> +
>>> +	alloced = PAGE_SIZE;
>>> +	p = buf = kmalloc(alloced, GFP_KERNEL);
>>> +	if (!buf)
>>> +		return -ENOMEM;
>>> +	
>>> +	p += print_sigset(buf, &pending->signal);
>>> +	p += sprintf(p, "\n");
>>> +
>>> +	list_for_each_entry(q, &pending->list, list) {
>>> +		info = &q->info;
>>> +		if (p-buf+215 > alloced) {
>>> +			int len=p-buf;
>>> +			char *buf2;
>>> +			alloced += PAGE_SIZE;
>>> +			buf2 = kmalloc(alloced, GFP_KERNEL);
>>> +			if (!buf2) {
>>> +				kfree(buf);
>>> +				return -ENOMEM;
>>> +			}
>>> +			memcpy(buf2, buf, alloced - PAGE_SIZE);
>>> +			kfree(buf);
>>> +			buf = buf2;
>>> +			p = buf+len;
>>> +		}
>>> +
>>> +		p += sprintf(p, "sig %d: user %d flags %d",
>>> +			info->si_signo, (int)q->user->uid, q->flags);
>>> +		p += sprintf(p, " errno %d code %d\n",
>>> +			info->si_errno, info->si_code);
>>> +
>>> +		switch(info->si_signo) {
>>> +		case SIGKILL:
>>> +			p += sprintf(p, "  spid %d suid %d\n",
>>> +				info->_sifields._kill._pid,
>>> +				info->_sifields._kill._uid);
>>> +			break;
>>> +		/* XXX skipping posix1b timers and signals for now */
>>> +		case SIGCHLD:
>>> +			p += sprintf(p, "  pid %d uid %d status %d utime %lu stime %lu\n",
>>> +				info->_sifields._sigchld._pid,
>>> +				info->_sifields._sigchld._uid,
>>> +				info->_sifields._sigchld._status,
>>> +				info->_sifields._sigchld._utime,
>>> +				info->_sifields._sigchld._stime);
>>> +			break;
>>> +		case SIGILL:
>>> +		case SIGFPE:
>>> +		case SIGSEGV:
>>> +		case SIGBUS:
>>> +#ifdef __ARCH_SI_TRAPNO
>>> +			p += sprintf(p, "  addr %lu trapno %d\n",
>>> +				(unsigned long)info->_sifields._sigfault._addr,
>>> +				info->_sifields._sigfault._trapno);
>>> +#else
>>> +			p += sprintf(p, "  addr %lu\n",
>>> +				(unsigned long)info->_sifields._sigfault._addr);
>>> +#endif
>>> +			break;
>>> +		case SIGPOLL:
>>> +			p += sprintf(p, "  band %ld fd %d\n",
>>> +				(long)info->_sifields._sigpoll._band,
>>> +				info->_sifields._sigpoll._fd);
>>> +			break;
>>> +		default:
>>> +			p += sprintf(p, "  Unsupported siginfo for signal %d\n",
>>> +				info->si_signo);
>>> +			break;
>>> +		}
>>> +	}
>>> +	*bufp = buf;
>>> +	return p-buf;
>>> +}
>> I think we are reaching the limit of /proc when we expose the pending siginfos.
> 
> Why?

well, we are really exposing the internals of signal delivery, which are
not that useful for /proc. IMO, it would be better to use an "opaque" to 
get/set the data we need.

C.


_______________________________________________
Containers mailing list
Containers@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: [PATCH] se401: fix "&& 0x" typo
Next Topic: [PATCH 2.6.21-rc6] [netfilter] early_drop imrovement
Goto Forum:
  


Current Time: Wed Oct 08 16:59:46 GMT 2025

Total time taken to generate the page: 0.08788 seconds