gcc (GCC) 4.6.0 20110419 (Red Hat 4.6.0-5)
我剛剛使用了sigaction,並且在將信號hanlder函數分配給sa_handler時我得到了堆棧轉儲。將sigaction聲明爲值類型的指針類型
這是我做過什麼用指針類型:
struct sigaction *new_act = NULL;
new_act->sa_handler = signal_handler; /* This line produces the stack dump */
sigaction(SIGINT, new_act, NULL);
這是我沒有使用值類型:
struct sigaction new_act;
new_act.sa_handler = signal_handler; /* No problem here */
sigaction(SIGINT, &new_act, NULL);
有什麼用指針類型的值類型的區別?
非常感謝您的任何建議,