--- sys/sys/thr.h.orig 2005-04-23 04:36:07.000000000 +0200 +++ sys/sys/thr.h 2007-08-03 21:36:55.000000000 +0200 @@ -30,6 +30,13 @@ #ifndef _SYS_THR_H_ #define _SYS_THR_H_ +#include + +#ifndef _SIZE_T_DECLARED +typedef __size_t size_t; +#define _SIZE_T_DECLARED +#endif + /* Create the thread in the suspended state. */ #define THR_SUSPENDED 0x0001 /* Create the system scope thread. */ @@ -52,12 +59,19 @@ * See pthread_* */ #ifndef _KERNEL +#include + +#ifndef _PID_T_DECLARED +typedef __pid_t pid_t; +#define _PID_T_DECLARED +#endif int thr_create(ucontext_t *ctx, long *id, int flags); int thr_new(struct thr_param *param, int param_size); int thr_self(long *id); void thr_exit(long *state); int thr_kill(long id, int sig); +int thr_kill2(pid_t pid, long id, int sig); int thr_suspend(const struct timespec *timeout); int thr_wake(long id); --- sys/kern/syscalls.master.orig 2006-10-10 15:19:47.000000000 +0200 +++ sys/kern/syscalls.master 2007-08-03 21:55:32.000000000 +0200 @@ -797,6 +797,32 @@ long id, void *uaddr, void *uaddr2); } 455 AUE_NULL MSTD { int thr_new(struct thr_param *param, \ int param_size); } +456 AUE_NULL UNIMPL sigqueue +457 AUE_NULL UNIMPL kmq_open +458 AUE_NULL UNIMPL kmq_setattr +459 AUE_NULL UNIMPL kmq_timedreceive +460 AUE_NULL UNIMPL kmq_timedsend +461 AUE_NULL UNIMPL kmq_notify +462 AUE_NULL UNIMPL kmq_unlink +463 AUE_NULL UNIMPL abort2 +464 AUE_NULL UNIMPL thr_set_name +465 AUE_NULL UNIMPL aio_fsync +466 AUE_NULL UNIMPL rtprio_thread +467 AUE_NULL UNIMPL nosys +468 AUE_NULL UNIMPL nosys +469 AUE_NULL UNIMPL __getpath_fromfd +470 AUE_NULL UNIMPL __getpath_fromaddr +471 AUE_NULL UNIMPL sctp_peeloff +472 AUE_NULL UNIMPL sctp_generic_sendmsg +473 AUE_NULL UNIMPL sctp_generic_sendmsg_iov +474 AUE_NULL UNIMPL sctp_generic_recvmsg +475 AUE_NULL UNIMPL pread +476 AUE_NULL UNIMPL pwrite +477 AUE_NULL UNIMPL mmap +478 AUE_NULL UNIMPL lseek +479 AUE_NULL UNIMPL truncate +480 AUE_NULL UNIMPL ftruncate +481 AUE_KILL MSTD { int thr_kill2(pid_t pid, long id, int sig); } ; Please copy any additions and changes to the following compatability tables: ; sys/compat/freebsd32/syscalls.master --- sys/compat/freebsd32/syscalls.master.orig 2007-08-03 21:58:19.000000000 +0200 +++ sys/compat/freebsd32/syscalls.master 2007-08-03 21:56:38.000000000 +0200 @@ -755,3 +755,29 @@ 455 AUE_NULL MSTD { int freebsd32_thr_new( \ struct thr_param32 *param, \ int param_size); } +456 AUE_NULL UNIMPL sigqueue +457 AUE_NULL UNIMPL kmq_open +458 AUE_NULL UNIMPL kmq_setattr +459 AUE_NULL UNIMPL kmq_timedreceive +460 AUE_NULL UNIMPL kmq_timedsend +461 AUE_NULL UNIMPL kmq_notify +462 AUE_NULL UNIMPL kmq_unlink +463 AUE_NULL UNIMPL abort2 +464 AUE_NULL UNIMPL thr_set_name +465 AUE_NULL UNIMPL aio_fsync +466 AUE_NULL UNIMPL rtprio_thread +467 AUE_NULL UNIMPL nosys +468 AUE_NULL UNIMPL nosys +469 AUE_NULL UNIMPL __getpath_fromfd +470 AUE_NULL UNIMPL __getpath_fromaddr +471 AUE_NULL UNIMPL sctp_peeloff +472 AUE_NULL UNIMPL sctp_generic_sendmsg +473 AUE_NULL UNIMPL sctp_generic_sendmsg_iov +474 AUE_NULL UNIMPL sctp_generic_recvmsg +475 AUE_NULL UNIMPL freebsd32_pread +476 AUE_NULL UNIMPL freebsd32_pwrite +477 AUE_NULL UNIMPL freebsd32_mmap +478 AUE_NULL UNIMPL freebsd32_lseek +479 AUE_NULL UNIMPL freebsd32_truncate +480 AUE_NULL UNIMPL freebsd32_ftruncate +481 AUE_KILL MNOPROTO { int thr_kill2(pid_t pid, long id, int sig); } --- sys/kern/kern_thr.c.orig 2007-08-03 22:04:31.000000000 +0200 +++ sys/kern/kern_thr.c 2007-08-03 22:10:18.000000000 +0200 @@ -48,6 +48,8 @@ #include +#include + #ifdef COMPAT_IA32 extern struct sysentvec ia32_freebsd_sysvec; @@ -371,6 +373,62 @@ } int +thr_kill2(struct thread *td, struct thr_kill2_args *uap) + /* pid_t pid, long id, int sig */ +{ + struct thread *ttd; + struct proc *p; + int error; + + AUDIT_ARG(signum, uap->sig); + + if (uap->pid == td->td_proc->p_pid) { + p = td->td_proc; + PROC_LOCK(p); + } else if ((p = pfind(uap->pid)) == NULL) { + return (ESRCH); + } + AUDIT_ARG(process, p); + + error = p_cansignal(td, p, uap->sig); + if (error == 0) { + if (uap->id == -1) { + if (uap->sig != 0 && !_SIG_VALID(uap->sig)) { + error = EINVAL; + } else { + error = ESRCH; + FOREACH_THREAD_IN_PROC(p, ttd) { + if (ttd != td) { + error = 0; + if (uap->sig == 0) + break; + tdsignal(ttd, uap->sig, SIGTARGET_TD); + } + } + } + } else { + if (uap->id != td->td_tid) { + FOREACH_THREAD_IN_PROC(p, ttd) { + if (ttd->td_tid == uap->id) + break; + } + } else + ttd = td; + if (ttd == NULL) + error = ESRCH; + else if (uap->sig == 0) + ; + else if (!_SIG_VALID(uap->sig)) + error = EINVAL; + else + tdsignal(ttd, uap->sig, SIGTARGET_TD); + } + } + PROC_UNLOCK(p); + return (error); +} + +int thr_suspend(struct thread *td, struct thr_suspend_args *uap) /* const struct timespec *timeout */ { --- sys/kern/sys_process.c.orig 2007-08-03 22:23:50.000000000 +0200 +++ sys/kern/sys_process.c 2007-08-03 22:44:44.000000000 +0200 @@ -777,14 +777,14 @@ sx_xunlock(&proctree_lock); proctree_locked = 0; } - /* deliver or queue signal */ - mtx_lock_spin(&sched_lock); - td2->td_flags &= ~TDF_XSIG; - mtx_unlock_spin(&sched_lock); - td2->td_xsig = data; p->p_xstat = data; p->p_xthread = NULL; if ((p->p_flag & (P_STOPPED_SIG | P_STOPPED_TRACE)) != 0) { + /* deliver or queue signal */ + mtx_lock_spin(&sched_lock); + td2->td_flags &= ~TDF_XSIG; + mtx_unlock_spin(&sched_lock); + td2->td_xsig = data; mtx_lock_spin(&sched_lock); if (req == PT_DETACH) { struct thread *td3; @@ -802,11 +802,10 @@ mtx_lock_spin(&sched_lock); thread_unsuspend(p); mtx_unlock_spin(&sched_lock); + } else { + if (data) + psignal(p, data); } - - if (data) - psignal(p, data); - break; case PT_WRITE_I: