Index: compat/linux/linux_file.c
===================================================================
RCS file: /home/ncvs/src/sys/compat/linux/linux_file.c,v
retrieving revision 1.107
diff -u -r1.107 linux_file.c
--- compat/linux/linux_file.c	29 Dec 2007 14:28:01 -0000	1.107
+++ compat/linux/linux_file.c	7 Jan 2008 22:23:11 -0000
@@ -47,6 +47,7 @@
 #include <sys/proc.h>
 #include <sys/stat.h>
 #include <sys/sx.h>
+#include <sys/socketvar.h>
 #include <sys/syscallsubr.h>
 #include <sys/sysproto.h>
 #include <sys/tty.h>
@@ -66,6 +67,7 @@
 #include <machine/../linux/linux.h>
 #include <machine/../linux/linux_proto.h>
 #endif
+#include <compat/linux/linux_file.h>
 #include <compat/linux/linux_util.h>
 
 int
@@ -1138,8 +1140,31 @@
 	struct file *fp;
 	long arg;
 	int error, result;
+	struct socket *so;
 
 	switch (args->cmd) {
+	case LINUX_F_SETSIG:
+		error = fget(td, args->fd, &fp);
+		if (error)
+			return (error);
+	   	if (fp->f_type == DTYPE_SOCKET) {
+			so = (struct socket *)fp->f_data;
+			if (so->so_sigio == NULL) {
+				error = fsetown_sig(td->td_proc->p_pid, &so->so_sigio, args->arg);
+				if (error) {
+					fdrop(fp, td);
+					return (error);
+				}
+			} else {
+				SIGIO_LOCK();
+				if (so->so_sigio == NULL)
+					return (EAGAIN);
+				so->so_sigio->sig = args->arg;
+				SIGIO_UNLOCK();
+			}
+		}
+		fdrop(fp, td);
+		return (0);
 	case LINUX_F_DUPFD:
 		return (kern_fcntl(td, args->fd, F_DUPFD, args->arg));
 
Index: kern/kern_sig.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/kern_sig.c,v
retrieving revision 1.353
diff -u -r1.353 kern_sig.c
--- kern/kern_sig.c	18 Dec 2007 20:39:13 -0000	1.353
+++ kern/kern_sig.c	7 Jan 2008 22:23:11 -0000
@@ -3211,6 +3211,9 @@
 		SIGIO_UNLOCK();
 		return;
 	}
+	if (sigio->sig != 0)
+		sig = sigio->sig;
+
 	if (sigio->sio_pgid > 0) {
 		PROC_LOCK(sigio->sio_proc);
 		if (CANSIGIO(sigio->sio_ucred, sigio->sio_proc->p_ucred))
Index: kern/kern_descrip.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/kern_descrip.c,v
retrieving revision 1.316
diff -u -r1.316 kern_descrip.c
--- kern/kern_descrip.c	3 Jan 2008 01:26:59 -0000	1.316
+++ kern/kern_descrip.c	7 Jan 2008 22:23:11 -0000
@@ -871,6 +871,12 @@
 int
 fsetown(pid_t pgid, struct sigio **sigiop)
 {
+	return (fsetown_sig(pgid, sigiop, 0));
+}
+
+int
+fsetown_sig(pid_t pgid, struct sigio **sigiop, int sig)
+{
 	struct proc *proc;
 	struct pgrp *pgrp;
 	struct sigio *sigio;
@@ -888,6 +894,7 @@
 	sigio->sio_pgid = pgid;
 	sigio->sio_ucred = crhold(curthread->td_ucred);
 	sigio->sio_myref = sigiop;
+	sigio->sig = sig;
 
 	sx_slock(&proctree_lock);
 	if (pgid > 0) {
Index: kern/sys_socket.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/sys_socket.c,v
retrieving revision 1.74
diff -u -r1.74 sys_socket.c
--- kern/sys_socket.c	24 Oct 2007 19:03:55 -0000	1.74
+++ kern/sys_socket.c	7 Jan 2008 22:23:11 -0000
@@ -181,6 +181,16 @@
 		/* Unlocked read. */
 		*(int *)data = (so->so_rcv.sb_state & SBS_RCVATMARK) != 0;
 		break;
+#define FSETSIG	123
+	case FSETSIG:
+		if (so->so_sigio == NULL)
+			error = fsetown_sig(td->td_proc->p_pid, &so->so_sigio,
+			    *(int *)data);
+		else {
+			SIGIO_LOCK();
+			so->so_sigio->sig = *(int *)data;
+			SIGIO_UNLOCK();
+		}
 	default:
 		/*
 		 * Interface/routing/protocol specific ioctls: interface and
Index: sys/sigio.h
===================================================================
RCS file: /home/ncvs/src/sys/sys/sigio.h,v
retrieving revision 1.3
diff -u -r1.3 sigio.h
--- sys/sigio.h	7 Jan 2005 02:29:24 -0000	1.3
+++ sys/sigio.h	7 Jan 2008 22:23:11 -0000
@@ -42,6 +42,7 @@
  *
  * (c)	const
  * (pg)	locked by either the process or process group lock
+ * (s)	locked by sigio lock
  */
 struct sigio {
 	union {
@@ -53,6 +54,7 @@
 					 * 	the reference to this structure */
 	struct	ucred *sio_ucred;	/* (c)	current credentials */
 	pid_t	sio_pgid;		/* (c)	pgid for signals */
+	int	sig;			/* (s)	signal to be sent */
 };
 #define	sio_proc	sio_u.siu_proc
 #define	sio_pgrp	sio_u.siu_pgrp
@@ -61,6 +63,7 @@
 
 pid_t	fgetown(struct sigio **sigiop);
 int	fsetown(pid_t pgid, struct sigio **sigiop);
+int	fsetown_sig(pid_t pgid, struct sigio **sigiop, int);
 void	funsetown(struct sigio **sigiop);
 void	funsetownlst(struct sigiolst *sigiolst);
 
