From: tan@hulab.hudson.co.jp (Yuuji Tanaka)
Subject: Re: about BREAK key
Organization: HUDSON SOFT, Sapporo, Japan.
X-Newsreader: TIN [version 1.1 PL6]
Distribution: fj
Date: Tue, 22 Dec 1992 06:29:09 GMT

$@EDCf!w%O%I%=%s$G$9!#:$$C$F$$$i$C$7$c$k$h$&$J$N$G%U%)%m!<$r!#(J

In article <ENCHAN.92Dec17153201@hcrlgw.crl.hitachi.co.jp>
   Takashi Endoh (enchan@hcrlgw.crl.hitachi.co.jp) wrote:
>$@!!$O$8$a$^$7$F!#1sF#!wF|N)$G$9!#(JX68000 $@$N%V%l!<%/%-!<$K$D$$$F!"(J
>$@#2E@$[$I:$$C$F$$$k$3$H$,$"$j!"2r7hK!$rA\$7$F$$$^$9!#(J
>
>(1) X68000 $@$G!"(Jbreak $@%-!<3d$j9~$_$G!"(Jbreak $@%-!<$,#32s2!$5$l$?$i(J
>   $@$"$k4X?t$r8F$S$@$7!"%V%l!<%/%-!<$,2!$5$l$?2s?t$,#32sL$K~$G(J
>   $@$"$C$?$i!"$=$N$^$^$J$K$b$7$J$$$G=hM}$rB39T$9$k!"$H$$$&;v$,(J
                      ^^^^^^^^^^^^^^^^^^^^^^^^
>   $@$d$j$?$$$N$G$9$,!"$I$&$d$C$?$i$h$$$N$G$7$g$&$+!#(J

^^^^$@$NItJ,$K$D$$$F$G$9$,!"(JHuman68k$@$G$O!"<B8=IT2DG=$G$9!#(J
$@2?8N$+$H8@$&$H!"#O#S$,(J break $@%-!<$r8!CN$7$F!"%f!<%6!<$N(J Ctrl+C $@=hM}$K(J
$@0\9T$7$F$7$^$&$H!"%f!<%6!<=hM}$+$i$NI|5"$O9M$($i$l$F$$$J$$$+$i$G$9!#(J
$@#O#S$O!"(JCtrl+C $@=hM}$N8F$S=P$7$K(J trap $@L?Na$r;H$C$F$$$^$9$,!"$3$N(J trap
$@L?Na$N2<$K$O!"%W%m%0%i%`$,%3!<%G%#%s%0$5$l$F$$$J$$$N$G!"%f!<%6!<=hM}(J
$@$+$iL5M}LpM}$KLa$m$&!J$D$^$j!"2?$b$7$J$$$G=hM}$rB39T$7$h$&!K$H$9$k$H(J
$@3N<B$KK=Av$9$k$G$7$g$&!#(J

$@L5M}LpM}$K=hM}$rB39T$9$k$J$i$P!"(Jsetjmp longjmp $@$9$k$7$+$"$j$^$;$s!#(J
$@#X#C$G%3!<%G%#%s%0$9$k$H!"(J

------sample.c------
#include    <stdio.h>
#include    <signal.h>
#include    <setjmp.h>

jmp_buf env;

int break_count = 0;

void    break_key(int sigs)
{
    signal(SIGINT,break_key);   /* break_key()$@$NCf$G(J ^C $@$5$l$k$H:$$k$N$G(J
                                   $@Ht$s$G$-$?$i$b$&0lEY%;%C%H(J */
    if (++break_count > 2) {
        break_count = 0;
        break_key_3_times();
    }
    longjmp(env,1);             /* setjmp $@$XLa$k(J */
                                /* return $@$7$F$7$^$&$H(J exit() $@$7$F(J
                                   $@$7$^$&$N$G!"(Jreturn $@$7$F$O$$$1$J$$(J */
}

int main()
{
    char buf[20];
    setjmp(env);                /* $@$3$3$KLa$k(J */
    signal(SIGINT,break_key);   /* $@La$C$F$-$?$i$b$&0lEY%;%C%H(J */
    printf("main\n");
    scanf("%10s",a);            /* Ctrl+C $@$r<u$1IU$1$k(J */
    printf("%s\n",a);
    return(0);
}
------sample.c------

$@$H!"$3$s$J46$8$G$7$g$&!#%7%'%k$,(J ^C $@$GI,$:%W%m%s%W%H$KLa$k$N$HF1$8$G$9!#(J

setjmp longjmp $@$N4D6-JQ?t(J env $@$rJ#?t8D;}$C$F!"4X?t(Jbreak_key()$@$G(J
$@La$j>l=j$rA*Br$9$l$P!"=hM}$rB39T$7$F$$$k!v$U$j!v$r$5$;$k;v$b$G$-$k(J
$@$G$7$g$&!#(J

$@Cm0U$H$7$F!"(Jsignal $@$K$h$jHt$V;~!"(Jlongjmp $@$K$h$jHt$V;~$K(J $@%9!<%Q!<%P%$%6(J
$@$H%f!<%6!<%b!<%I$N%b!<%I$,$/$$0c$C$F$$$k$H!"K=Av$7$^$9!#$^$?!"(Jreturn
$@$7$F!JO@M}E*$K!K>C$($F$7$^$C$?4X?tFb$K(J longjmp $@$7$F$7$^$o$J$$$h$&$K!#(J

$@!t$I$&$9$l$P2sHr$G$-$k$+$O!"%W%m%0%i%`$GHS?)$C$F$k?M$N%N%&%O%&$J$N$G(J...
$@!t2sHrJ}K!$O<+J,$G9M$($^$7$g$&!#(J

>(2) break $@%-!<$K$h$k3d$j9~$_$r%^%9%/$9$k$K$O$I$&$7$?$iNI$$$N$G(J
>$@!!!!$7$g$&$+!#(Jbreak=kill $@$H@_Dj$7$F$b!"(Jscanf() $@$NCf$H$+$+$i(J
>    break $@$K$h$k3d$j9~$_$,$+$+$C$F$7$^$$!"$&$^$/9T$-$^$;$s!#(J

$@$3$l$O!"2?$+$N4V0c$$$G$O!)(J break kill $@$7$F$$$k8B$j!"(Jscanf $@$G;_$^$k(J
$@;v$OL5$$H&$G$9!#>e5-$K<($7$?%5%s%W%k$r(J break kill $@$G<B9T$9$k$H!"(J

A>break kill
A>sample
main
aaa^C^C^Cbbb
aaabbb
A>break
break $@$O(J <kill> $@$G$9(J
A>

$@$H!"$J$j$^$7$?$,!#(J
--
   /   / /   /  __ \    ___/  _ \    \   / $@3t<02q<R%O%I%=%s!!OB(J  $@>:OB(J  $@:8?X(J
  ___ / /   /  /   /  \_ \   /  /  /  \ /  $@EDCf!!M5Fs(J (Yuuji Tanaka)
_/  _/ \__$@!?(J ____$@!?(J ____$@!?(J \__$@!?(J _/   _/   tan@hulab.hudson.co.jp