Home
Developer Resources
QNX RTOS v4
QNX RTOS v4 Knowledge Base

QNX RTOS v4 Knowledge Base

Foundry27
Foundry27
QNX RTOS v4 project
Resources

QNX RTOS v4 Knowledge Base

Title Pterm adjusts a terminal size
Ref. No. QNX.000009857
Category(ies) Input Devices, Development, Configuration, Character I/O
Issue We use qtalk via pterm windows and often at a bigger size than 80x25.
We want pterm to send a stty rows=...command to the shell, as it does when the emulating mode is changed.
Can we issue the 'stty' command by hand?




Solution Resizing a window sends a SIGWINCH signal to the application running in the window. You do not need pterm's help here. You just need to run a small program that injects the stty command into your keyboard whenever you resize the window. For example:
(i.e. run it as "blah qtalk ...")

x09#include <stdio.h>
x09#include <signal.h>
x09#include <stdlib.h>
x09#include <process.h>
x09#include <sys/dev.h>
x09#include <sys/wait.h>
x09
x09#ifdef __USAGE
x09%C program[arguments]
x09#endif
x09
x09static void winch(int s){
x09x09int r, c;
x09x09if(dev_size(0, -1, -1, &r, &c) == 0){
x09x09x09char buf[32];
x09x09x09dev_insert_chars(0, sprintf(buf, "stty rows = %d,%dn", r, c), buf);
x09x09}
x09}
x09int main(int argc, char **argv){
x09x09const char *cmd;
x09x09if((cmd = *++argv) == NULL)
x09x09x09fputs("Need a command to runn", stderr);
x09x09else{
x09x09x09int pid;
x09x09x09if((pid = spawnvp(P_NONWAIT, cmd, argv)) < 0)
x09x09x09x09perror(cmd);
x09x09}else{
x09x09x09int status;
x09x09x09signal(SIGWINCH, winch);
x09x09x09while(waitpid(pid, &status, 0) != pid)
x09x09x09x09;
x09x09x09if(WIFEXITED(status))
x09x09x09x09return WEXITSTATUS(status);
x09x09}
x09x09return EXIT_FAILURE;
x09}

x09