ksh can read stdin on /dev/ser1 but other programs can't!

Greetings

The startup script included below will spawn a ksh session that reads stdin just fine.

I can type commands - and get output on stdout/stderr - all is good.

With the very simple program included below started in the three listed ways - I can never seem to read stdin. Just to be clear. ksh will start fine from the startup script… esh seems to not be able to read from stdin in… and finally the included program if started from a ksh prompt - won’t read stdin either.

/dev/ser1 == /dev/console

[+script] .script = {
    procmgr_symlink ../../proc/boot/libc.so.2 /usr/lib/ldqnx.so.2
   	
	display_msg ******************************************************
    display_msg Greetings people of earth !
    display_msg ******************************************************
	
	#######################################################################
    ## NETWORK driver 
    ##  - substitute your IP address for 1.2.3.4
    ##  - substitute your MAC address for 003322446577
    #######################################################################
    display_msg Starting ethernet device
    # TODO - the mac and ip must come from configuration files
    # so io-net and the driver should be started from the applications manager
    # after the manager has read the board's configuration settings.
    #io-net -dxtemac mac=003322446577 -ptcpip
    netcfg
    #waitfor /dev/io-net/en0 10
    #ifconfig en0 192.168.20.243
    
    #######################################################################
    ## SERIAL driver - UART 1 
    #######################################################################
    devc-seruartlite -e -b115200 &
    #waitfor /dev/ser1
    #reopen /dev/ser1
	
	display_msg Starting system log services...
    slogger &
    devc-pty &
	pipe &

    #######################################################################
    ## REMOTE_DEBUG (gdb or Momentics)
    ##  - refer to the help documentation for the gdb, qconn and the IDE
    ##    for more information on remote debugging
    ##  - the commands shown require that a NETWORK driver is enabled too
    #######################################################################
    display_msg Starting Remote Debug services...
    #
    waitfor /dev/ptyp0 4
    waitfor /dev/socket 4
    qconn port=8000 &

    #######################################################################
    ## These env variables are inherited by all the programs which follow
    #######################################################################
    HOSTNAME=xilinx
    SYSNAME=nto
    TERM=qansi
    SHELL=/bin/sh
    HOME=/
    PATH=:/proc/boot:/bin:/usr/bin:/opt/bin:/usr/photon/bin
    LD_LIBRARY_PATH=:/proc/boot:/lib:/usr/lib:/lib/dll:/opt/lib:/usr/photon/lib:/usr/photon/dll
    PHOTON_PATH=/usr/photon
    PHOTON=/dev/photon
    PHFONT=/dev/phfont

	#display_msg starting login...
	#login -f &
	
	#display_msg Starting telnetd...
    #telnetd -debug 6888
   	
   	# Start inetd
	display_msg Starting inetd..
	inetd &
	
	display_msg Starting single instance telnet...
	telnetd -D options -debug 6867 &
	
    display_msg Starting ksh...
    reopen /dev/ser1
	[+session] ksh &
}

From a ksh prompt.

  1. ./test - can’t read stdin
  2. ./test & - can’t read stdin
  3. exec ./test - can’t read stdin

If I spawn esh instead of ksh esh can’t read stdin either !


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char * argv[])
{
	char * str = "Enter some data!\r\n";
	char r;
	char buf[0x20];
	int rx = 0, fd = 0;
	
	while(1){
		
		write(1, str, strlen(str));
		rx = read(0, &r, 1);
		snprintf(buf, 0x1f, "read %d bytes byte = %c\r\n", rx, r);
		write(1, buf, strlen(buf));
	}
	return 0;
}

I’ve fired this past QNX basic support and got not much help… any input is greatly appreciated !

Magnificopaddy,

In your simple program you should be checking the return codes/errno from read() and write().

If you do, you may find your answer.

I don’t remember if you have to specifically open stdin via an open() call before trying to get input from it or not. But that could be your problem.

Tim