v6 unix のシグナルハンドラ

rtt 命令で戻る、がビンゴらしい記述を発見。

From the fact that both PC and PSW are put on the user stack, and both need to be restored after signal handler is done, we can know that the signal handler returns with the rtt instruction instead of the rts instruction. rtt restores both PS and PSW from top of stack, while rts only restores PC from stack.

L10 より引用
まだスタックポインタな問題は片付いておりませんがちょっと気持ちてきに楽になったカンジ。

ちなみに

simh の中で簡単なシグナル処理を書いて云々しようとしたんですが、テキストファイルが壊れまくるのに根負けしてしまいましたorz
ed とか使うの久しぶりでした。以前 sed さえ使えない壊しかたをしてしまい、一度だけ使ったことがある ed ですが無論使い方など覚えている訳もなし。つうか、入力できて保存をした上で sync までしてるのに何故に壊れるんだろ。
書こうとしてたのは以下なカンジ。

static sig_usr(int signo)
{
    if(signo == SIGUSR1)
        printf("received SIGUSR1\n");

    return;
}

main(void)
{
    if(signal(SIGUSR1, sig_usr) == SIG_ERR)
        printf("can't catch SIGUSR1\n");

    return 0;
}

printf とか勝手に使って良いのかなぁ。いちおう hello world では勝手に使って何とかなりましたが。てか実行したい訳ではなくってシグナルハンドラな手続きがどうなるか、を見たいのか。
引数取ったりしてるけど大丈夫なのかなぁ。つかそもそも逆アセ可能なのかもアレ。