poll unable to access stdin on VMS


Topic author
greg@tssolutions.com.au
Active Contributor
Posts: 32
Joined: Wed May 29, 2024 10:29 am
Reputation: 0
Location: Australia
Status: Offline
Contact:

poll unable to access stdin on VMS

Post by greg@tssolutions.com.au » Sun Aug 04, 2024 11:40 pm

The following works fine on Linux but not VMS
VSI C x86-64 V7.5-009 (GEM 50XBR) on OpenVMS x86_64 V9.2-2

Code: Select all

#include <unistd.h>
#include <stdio.h>
#include <poll.h>
#include <string.h>
#include <errno.h>

int main(int argc, char **argv)
{
  int i,inlen, sts;
  struct pollfd poll_fds[4];
  nfds_t poll_nfds;
  char buff[4096]={0};

  poll_fds[0].fd=fileno(stdin);
  poll_fds[0].events=POLLIN;
  poll_nfds=1;

  sts=poll(poll_fds,poll_nfds,10000);
  if(sts<0)
  {
     printf("ppoll: %.100s, errno=%d\n", strerror(errno), errno);
  }
  for(i=0; i<poll_nfds;i++)
  {
     if((poll_fds[i].revents & POLLIN) !=0 )
     {
       inlen=read(poll_fds[i].fd,buff,sizeof(buff));
       printf("read[%d]: %.60s\n",inlen, buff);
     }
  }
  printf("sts=%d revents=%08x\n",sts, poll_fds[0].revents);

}
linux>
$ ./t.exe
en
read[3]: en

sts=1 revents=00000001

vms>
$ run test_poll
ppoll: i/o error, errno=5
sts=-1 revents=00000000
Last edited by greg@tssolutions.com.au on Mon Aug 05, 2024 12:25 am, edited 1 time in total.
gt (260295)
VMS Ambassador
Downunder


Topic author
greg@tssolutions.com.au
Active Contributor
Posts: 32
Joined: Wed May 29, 2024 10:29 am
Reputation: 0
Location: Australia
Status: Offline
Contact:

Re: poll unable to access stdin on VMS

Post by greg@tssolutions.com.au » Fri Nov 22, 2024 5:17 am

That is using mailboxes MBA not pipes MPA
gt (260295)
VMS Ambassador
Downunder


pustovetov
VSI Expert
Active Contributor
Posts: 47
Joined: Thu Sep 14, 2023 1:26 am
Reputation: 0
Status: Offline

Re: poll unable to access stdin on VMS

Post by pustovetov » Mon Nov 25, 2024 11:19 am

greg@tssolutions.com.au wrote:
Fri Nov 22, 2024 5:17 am
That is using mailboxes MBA not pipes MPA
Sorry, I didn't understand you. Yes, DCL pipes don't work with poll. I'll try to fix it, but I'm unsure if it will succeed.


frenchie68
Visitor
Posts: 2
Joined: Wed Nov 27, 2024 10:08 am
Reputation: 0
Status: Offline

Re: poll unable to access stdin on VMS

Post by frenchie68 » Wed Nov 27, 2024 10:28 am

@greg: I can feel your pain. You're using poll() and I am using select(). Not sure whether or not poll() is
POSIX.1--I'd have to check. I am running 9.2-3 on x86_64 in VirtualBox 7. The code I am using has been
validated under Linux (posix), OpenSolaris 09/06 (curses and posix) but under OpenVMS/curses select()
on fileno(stdin) seems to always return 0. So input from the terminal is never acknowledged, which is very
embarrassing for an interactive computer game (Pac-Man in text mode for the VT420).

I have to avow that upon compilation, I get the following warning:

Code: Select all

mit@kir4:~/Desktop$ ssh -4 a1

 Welcome to OpenVMS (TM) x86_64 Operating System, Version E9.2-3  
mit@a1's password: 

    Last interactive login on Wednesday, 27-NOV-2024 15:36:55.18
    Last non-interactive login on Tuesday, 26-NOV-2024 10:29:52.50
    1 failure since last successful login
$ set def [.src.pacman]
$ @make

  cbreak();                              // Switch to cbreak mode
..^
%CC-I-IMPLICITFUNC, In this statement, the identifier "cbreak" is implicitly dec
lared as a function.
at line number 187 in file DKA200:[USERS.MIT.SRC.PACMAN]PACMAN.C;2
$ 
This is with:

VSI C x86-64 X7.6-028 (GEM 50Y92) on OpenVMS x86_64 E9.2-3
Attachments
make-com.txt
(32 Bytes) Downloaded 31 times
sf420-hex.c
(33.87 KiB) Downloaded 41 times
pacman.c
(44.27 KiB) Downloaded 42 times
Last edited by frenchie68 on Thu Nov 28, 2024 10:45 am, edited 3 times in total.


pustovetov
VSI Expert
Active Contributor
Posts: 47
Joined: Thu Sep 14, 2023 1:26 am
Reputation: 0
Status: Offline

Re: poll unable to access stdin on VMS

Post by pustovetov » Fri Nov 29, 2024 10:24 am

frenchie68 wrote:
Wed Nov 27, 2024 10:28 am
@greg: I can feel your pain. You're using poll() and I am using select().
On VMS select() only works with sockets. So try changing pacman code to use poll().
cbreak(); // Switch to cbreak mode
..^
%CC-I-IMPLICITFUNC, In this statement, the identifier "cbreak" is implicitly dec
lared as a function.
Try to use the _BSD44_CURSES define.


frenchie68
Visitor
Posts: 2
Joined: Wed Nov 27, 2024 10:08 am
Reputation: 0
Status: Offline

Re: poll unable to access stdin on VMS

Post by frenchie68 » Mon Dec 02, 2024 11:38 am

Well, I upgraded to the latest OpenVMS x86_64 available version (9.2-3 as released on 11/20/2024). The attached program runs just fine under OpenSolaris 09/06. I suspect it would run as well under Linux if libncurses was not so completely broken.

Calling poll on fileno(stdin) still results in EIO and no fun at all. I have included a sample test program.
Attachments
polltest.c
(2.18 KiB) Downloaded 16 times

Post Reply