在include/linux/shed.h中定义了一个结构体:
/*
* NOTE! "signal_struct" does not have it's own
* locking, because a shared signal_struct always
* implies a shared sighand_struct, so locking
* sighand_struct is always a proper superset of
* the locking of signal_struct.
*/
struct
signal_struct {
…
/* job control IDs */
pid_t pgrp;
struct pid *tty_old_pgrp;
union {
pid_t session __deprecated;
pid_t __session;
};
…
};
在include/linux/init_task.h中定义了一个宏来对这个结构体进行初始化:
#define
INIT_SIGNALS(sig) { /
.count = ATOMIC_INIT(1), /
.wait_chldexit = __WAIT_QUEUE_HEAD_INITIALIZER(sig.wait_chldexit),/
.shared_pending = { /
.list = LIST_HEAD_INIT(sig.shared_pending.list), /
.signal = {{0}}}, /
.posix_timers = LIST_HEAD_INIT(sig.posix_timers), /
.cpu_timers = INIT_CPU_TIMERS(sig.cpu_timers), /
.rlim = INIT_RLIMITS, /
.pgrp = 0, /
.tty_old_pgrp = NULL, /
{ .__session = 0}, /
}
在这里
{ .__session = 0}, /
会引发一个错误:
"../../arch/blackfin/kernel/init_task.c", line 38: cc0136: error: union
"<unnamed>" has no field "__session"
static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
怎么看都有__session这个成员啊,实际引发这个错误的原因是在结构体中使用了未命名的union。因此必须做如下修改:
struct
signal_struct {
…
/* job control IDs */
pid_t pgrp;
struct pid *tty_old_pgrp;
union {
pid_t session __deprecated;
pid_t __session;
}signal_struct_session;
…
};
其实就是随便给这个union定义一个变量。