poll unable to access stdin on VMS


Topic author
greg@tssolutions.com.au
Active Contributor
Posts: 36
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: 36
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
Valued Contributor
Posts: 58
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.

User avatar

frenchie68
Contributor
Posts: 20
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 73 times
sf420-hex.c
(33.87 KiB) Downloaded 82 times
pacman.c
(44.27 KiB) Downloaded 86 times
Last edited by frenchie68 on Thu Nov 28, 2024 10:45 am, edited 3 times in total.


pustovetov
VSI Expert
Valued Contributor
Posts: 58
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.

User avatar

frenchie68
Contributor
Posts: 20
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 61 times

User avatar

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

Re: poll unable to access stdin on VMS

Post by frenchie68 » Thu Dec 05, 2024 3:02 pm

Hi guys,

Can we please at least make sure this is passed up to the engineering team and that it will be addressed in a later release?

Best regards.

Francois Laagel
VMS Ambassador
Last edited by frenchie68 on Thu Dec 05, 2024 3:09 pm, edited 1 time in total.

User avatar

arne_v
Senior Member
Posts: 625
Joined: Fri Apr 17, 2020 7:31 pm
Reputation: 0
Location: Rhode Island, USA
Status: Offline
Contact:

Re: poll unable to access stdin on VMS

Post by arne_v » Thu Dec 05, 2024 3:17 pm

Vitaly Pustovetov is part of engineering team, so they know about this thread.
Arne
arne@vajhoej.dk
VMS user since 1986


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

Re: poll unable to access stdin on VMS

Post by pustovetov » Thu Dec 05, 2024 3:43 pm

frenchie68 wrote:
Thu Dec 05, 2024 3:02 pm
Can we please at least make sure this is passed up to the engineering team and that it will be addressed in a later release?
I apologize for the delay. I wanted to install 9.2-3 and check the work of your example. With the new CRTL that comes with 9.2-3, there should not be an issue with terminal input as in your case. So far I've only checked it on 9.2-2 but with the new CRTL. Our curses are broken of course, but the poll works.
On Linux:
OnLinux.jpg
On OpenVMS:
OnVMS.jpg

User avatar

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

Re: poll unable to access stdin on VMS

Post by frenchie68 » Fri Dec 06, 2024 9:38 am

Very nice, Vitaly! Is there an ETA with respect to the availability of the new CRTL?

I ultimately managed to get polltest.c to work under Linux libncurses5. Boy, it took me almost a full
day to figure out what the proper procedure was. Jamie Zawinsky was definitely right when he said

"Linux is only free if your time has no value."

I have attached the Linux 32 bit build script, just in case someone else might be interested.

Note: this targets gcc 7.5. More recent versions might be less particular!
Attachments
mklinux_sh.txt
(195 Bytes) Downloaded 43 times
Last edited by frenchie68 on Fri Dec 06, 2024 9:58 am, edited 1 time in total.

User avatar

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

Re: poll unable to access stdin on VMS

Post by frenchie68 » Sat Dec 28, 2024 6:46 am

pustovetov wrote:
Thu Dec 05, 2024 3:43 pm
frenchie68 wrote:
Thu Dec 05, 2024 3:02 pm
Can we please at least make sure this is passed up to the engineering team and that it will be addressed in a later release?
I apologize for the delay. I wanted to install 9.2-3 and check the work of your example. With the new CRTL that comes with 9.2-3, there should not be an issue with terminal input as in your case. So far I've only checked it on 9.2-2 but with the new CRTL. Our curses are broken of course, but the poll works.
On Linux:
OnLinux.jpg
On OpenVMS:
OnVMS.jpg
Agreed: there should not be a problem. And yet there is one even with the latest software available from the service platform. Under OpenVMS 9.2-3, I get:

Code: Select all

poll() failed: i/o error
The outcome is the same whether I log in from ssh or from a real terminal. My software setup is as follows:

Code: Select all

$ sh sys/noproc
OpenVMS E9.2-3  on node A1   28-DEC-2024 12:53:10.69   Uptime  4 19:41:58
$ prod sh prod
------------------------------------ ----------- ---------
PRODUCT                              KIT TYPE    STATE
------------------------------------ ----------- ---------
VMSPORTS X86VMS PERL534 T5.34-0      Full LP     Installed
VSI X86VMS AVAIL_MAN_BASE E9.2-3     Full LP     Installed
VSI X86VMS C V7.6-1                  Full LP     Installed
VSI X86VMS CMS V4.8-12               Full LP     Installed
VSI X86VMS CURL V8.0-1B              Full LP     Installed
VSI X86VMS CXX V10.1-2               Full LP     Installed
VSI X86VMS DECSET V13.0-2            Full LP     Installed
VSI X86VMS DTM V4.5-7                Full LP     Installed
VSI X86VMS DWMOTIF V1.8-1            Full LP     Installed
VSI X86VMS DWMOTIF_SUPPORT E9.2-3    Full LP     Installed
VSI X86VMS ENVMGR V1.9-6             Full LP     Installed
VSI X86VMS GIT V2.44-1A              Full LP     Installed
VSI X86VMS KERBEROS V3.3-3           Full LP     Installed
VSI X86VMS LSE V5.3-3                Full LP     Installed
VSI X86VMS MMS V4.0-5                Full LP     Installed
VSI X86VMS OPENSSH V8.9-1H01         Full LP     Installed
VSI X86VMS OPENVMS E9.2-3            Platform    Installed
VSI X86VMS SCA V5.2-3                Full LP     Installed
VSI X86VMS SSL111 V1.1-1W            Full LP     Installed
VSI X86VMS SSL3 V3.0-15              Full LP     Installed
VSI X86VMS TCPIP V6.0-26             Full LP     Installed
VSI X86VMS VMS E9.2-3                Oper System Installed
------------------------------------ ----------- ---------
22 items found
$ 

I have attached the reproducer and the Linux 32 bit build script. For the record, this
issued was first reported on this forum sometime in August 2024.
Attachments
polltest.c
(2.18 KiB) Downloaded 16 times
mklinux_sh.txt
(166 Bytes) Downloaded 14 times
Last edited by frenchie68 on Sat Dec 28, 2024 6:54 am, edited 2 times in total.

Post Reply