Hello, Manager!

On Tue, 13 Apr 1999, Manager wrote:

>HOW to disable the suspend process key "^Z",,or to change it to something
>like ^O. AS for db package uses ^Z too....and cant use that key ?

To disable control processing ( actually signal processing ), use

'stty -isig' to stop and 'stty -isig' to start signal processing.

I couldn't find how to change suspending symbol with stty, so I wrote
my own program for doing this. It requires bsd library to be installed.

To compile : use 'gcc -o setsusp setsusp.c -lbsd'

Bye.
--
Flee at once, all is discovered.

--
    With best of best regards, Pawel S. Veselov (aka Black Angel)
       Web page : http://i.am/BlackAngel | ICQ UIN : 5252265
                   Internet e-mail : [EMAIL PROTECTED]
#include <stdio.h>
#include <bsd/sgtty.h>
#include <stdlib.h>

char *get_use_char(char);

void main(int argc, char **argv) {

    struct ltchars *ltc;
    unsigned char ch0, ch1;

    ltc = malloc(sizeof(struct ltchars));

    if (!ltc) {
        fprintf(stderr, "Out of memory!\n");
        exit(127);
    }

    if (ioctl(0, TIOCGLTC, ltc)<0) {
        perror("ioctl");
        exit(1);
    }

    if (argc<2) {
        fprintf(stdout, "Current suspend character: %d(%s)\n",
                ltc->t_suspc,get_use_char(ltc->t_suspc));
        exit(1);
    }


    /* parse command line */

    ch0 = argv[1][0];
    ch1 = argv[1][1];

    if (ch0 == '^') {
        if ((unsigned char)(ch1 - 'a') < 32) {      /* do upcase */
            ch1 -= 32;
        }
        if ((unsigned char)(ch1 - '@') < 32) {

            ch1 -= '@';
            ch0 = ch1;

        } else {
            fprintf(stderr, "Invalid character!\n");
            exit(1);
        }
    } else if (ch0 == '#') {
        ch0 = atoi(argv[1]+sizeof(char));
    } else if (ch0 == '\\') {
        ch0 = ch1;
    }

    ltc->t_suspc = ch0;
    ltc->t_dsuspc = ch0;
    
    if (ioctl(0, TIOCSLTC, ltc)<0) {
        perror("ioctl");
    }
}

char *get_use_char(char ch) {

    char *s = malloc(3*sizeof(char));

    if (!s) {
        fprintf(stderr,"Out of memory!\n");
        exit(127);
    }

    s[3] = s[2] = 0;
    
    if (ch < 32) {
        s[0] = '^';
        s[1] = ch + '@';
    } else {
        s[1] = ch;
    }

    return s;
    
}

Reply via email to