예제 #1
0
static bool TryQConsole( void )
{
    struct _psinfo              psinfo;
    struct _sidinfo             info;
    struct _dev_info_entry      dev;
    char                        *ptr;
    const char                  *term;

    if( qnx_psinfo( PROC_PID, getpid(), &psinfo, 0, 0 ) != getpid() ) {
        StartupErr( "unable to obtain process information" );
    }
    if( qnx_sid_query( PROC_PID, psinfo.sid, &info ) != psinfo.sid ) {
        StartupErr( "unable to obtain console name" );
    }
    ptr = info.tty_name + strlen( info.tty_name );
    for( ;; ) {
        --ptr;
        if( *ptr < '0' || *ptr > '9' ) {
            break;
        }
    }
    if( DbgConsole != 0 ) {
        ptr[1] = '0' + DbgConsole / 10;
        ptr[2] = '0' + DbgConsole % 10;
        ptr += 2;
    }
    ptr[1] = NULLCHAR;
    DbgConHandle = open( info.tty_name, O_RDWR );
    if( DbgConHandle == -1 ) {
        StartupErr( "unable to open system console" );
    }
    term = getenv( "TERM" );
    if( term != NULL && strcmp( term, "qnxw" ) == 0 ) {
        /* in QNX windows */
#define PROP_STRING     "\033\"pwd\""
        write( DbgConHandle, PROP_STRING, sizeof( PROP_STRING ) - 1 );
    }

    ConCtrl = console_open( DbgConHandle, O_WRONLY );
    if( ConCtrl == NULL ) {
        close( DbgConHandle );
        return( false );
    }
    if( dev_info( DbgConHandle, &dev ) == -1 ) {
        StartupErr( "unable to obtain console information" );
    }
    DbgConsole = dev.unit;
    console_size( ConCtrl, DbgConsole, 0, 0, &PrevLines, &PrevColumns );
    console_size( ConCtrl, DbgConsole, DbgLines, DbgColumns, 0, 0 );
    InitConsole = console_active( ConCtrl, -1 );
    return( true );
}
예제 #2
0
파일: ps.c 프로젝트: vocho/openqnx
char *proctty(void) {
    struct _sidinfo si;
    char *p;

    if (qnx_sid_query(pm, ps.sid, &si) != ps.sid)
	return "*";
    if (p = strchr(si.tty_name + 2, '/')) *p = 0;
    else return "*";
    if (p = strrchr(p + 1, '/')) p++;
    else p = "";
    sprintf(buffer, "[%s]%s", si.tty_name + 2, p);
    return buffer;
}