Author Topic: poll() and select()  (Read 11006 times)

Jochen Schäfer

  • Sr. Member
  • ****
  • Posts: 306
  • Karma: +27/-0
    • View Profile
poll() and select()
« on: June 23, 2017, 09:58:10 pm »
I'm trying to port multitail, but it seems that select() as well as poll() doesn't seem to work.
I have attached my test programs, which both should work. Both  return with EINVAL.
So, am I missing something or is the OS/2 implementation buggy?
Can somebody point me to some already ported code, which uses poll or select?

Valery Sedletski

  • Sr. Member
  • ****
  • Posts: 368
  • Karma: +2/-0
    • View Profile
Re: poll() and select()
« Reply #1 on: June 23, 2017, 10:41:17 pm »
OS/2 implementation of select() supports sockets, only. Not files.

Jochen Schäfer

  • Sr. Member
  • ****
  • Posts: 306
  • Karma: +27/-0
    • View Profile
Re: poll() and select()
« Reply #2 on: June 23, 2017, 10:52:37 pm »
That explains a lot.
Do we have an OS/2 API for something like this?
« Last Edit: June 23, 2017, 11:05:14 pm by Jochen Schäfer »

Valery Sedletski

  • Sr. Member
  • ****
  • Posts: 368
  • Karma: +2/-0
    • View Profile
Re: poll() and select()
« Reply #3 on: June 24, 2017, 12:10:55 am »
You could create a separate threads for polling each file descriptor, and posting a semaphore if ready. Then use DosWaitMuxWaitSem on a set of those semaphores, for example. Or, create your own select/poll implementation supporting files under the hood.
« Last Edit: June 24, 2017, 12:26:35 am by Martin Iturbide »

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4696
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: poll() and select()
« Reply #4 on: June 24, 2017, 12:25:33 am »
Hi Jochen.

Talking about the API I'm trying my best to update the OS/2 API Project on the EDM/2 wiki, but seems too be too much work for one man.  Check that page, and even that it may be incomplete, it may give you the pointers to find the rest of the documentation online.

Regards
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4775
  • Karma: +99/-1
    • View Profile
Re: poll() and select()
« Reply #5 on: June 24, 2017, 02:42:40 am »
That explains a lot.
Do we have an OS/2 API for something like this?

No, the current select is basically the native OS/2 one. EMX had a much better select() if you wanted to go that route, but it is missing a lot of current stuff, default GCC was 2.8.1 and newest on it was 3.03.
Libcx has a poll() implementation, if your building with the YUM/RPM environment, probably a good idea to add -lcx to LDFLAGS

Jochen Schäfer

  • Sr. Member
  • ****
  • Posts: 306
  • Karma: +27/-0
    • View Profile
Re: poll() and select()
« Reply #6 on: June 24, 2017, 10:00:13 am »
I should have stated that my setup relies on YUM.
Yes, I used the libcx version of poll, but that also doesn't work.
If EMX had a better version, perhaps I should look into the sources to get some hints.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4775
  • Karma: +99/-1
    • View Profile
Re: poll() and select()
« Reply #7 on: June 24, 2017, 10:46:50 am »
I should have stated that my setup relies on YUM.
Yes, I used the libcx version of poll, but that also doesn't work.
If EMX had a better version, perhaps I should look into the sources to get some hints.

The sources and binaries are at http://hobbes.nmsu.edu/h-browse.php?dir=/pub/os2/dev/emx/v0.9d.
The problem is licence incompatibility. kLIBC which yum installs is BSD and LGPL while the EMX libc is pure GPL. kLIBC does use a lot of EMX utilities and is mostly compatible but the libc itself was contracted by IBM to not be GPL. kLIBC was written mostly for one purpose, compiling Mozilla.

Jochen Schäfer

  • Sr. Member
  • ****
  • Posts: 306
  • Karma: +27/-0
    • View Profile
Re: poll() and select()
« Reply #8 on: June 24, 2017, 11:58:21 am »
Thanks for the hints.
I think, I will need to reimplement that part of multitail. So, I need some hints, which OS/2 APIs are required.
But I also will look at klibc source.
« Last Edit: June 24, 2017, 12:05:09 pm by Jochen Schäfer »

Paul Smedley

  • Hero Member
  • *****
  • Posts: 2089
  • Karma: +159/-0
    • View Profile
Re: poll() and select()
« Reply #9 on: June 25, 2017, 12:14:28 am »
Hey Jochen,


I'm trying to port multitail, but it seems that select() as well as poll() doesn't seem to work.
I have attached my test programs, which both should work. Both  return with EINVAL.
So, am I missing something or is the OS/2 implementation buggy?
Can somebody point me to some already ported code, which uses poll or select?

Check for pipe() usage - klibc select() won't work on a pipe()'d socket - replace pipe with socketpair....

Cheers,

Paul

Herwig Bauernfeind

  • Newbie
  • *
  • Posts: 39
  • Karma: +2/-0
    • View Profile
Re: poll() and select()
« Reply #10 on: June 25, 2017, 09:09:29 am »
I suggest to talk to Dmitriy Kuminov about the implementation in libcx.

We had to deal with the same problem on Samba.

Jochen Schäfer

  • Sr. Member
  • ****
  • Posts: 306
  • Karma: +27/-0
    • View Profile
Re: poll() and select()
« Reply #11 on: June 25, 2017, 10:34:06 am »
Hey Jochen,

I don't think that multitail opens sockets, it just observes some files.
Check for pipe() usage - klibc select() won't work on a pipe()'d socket - replace pipe with socketpair....

Cheers,

Paul
I don't thick that multitail opens any sockets, it just observes some files.

Jochen Schäfer

  • Sr. Member
  • ****
  • Posts: 306
  • Karma: +27/-0
    • View Profile
Re: poll() and select()
« Reply #12 on: June 25, 2017, 10:35:47 am »
I suggest to talk to Dmitriy Kuminov about the implementation in libcx.
How?

Edit: I meant, how can I contact him?
« Last Edit: June 25, 2017, 12:48:54 pm by Jochen Schäfer »

xynixme

  • Guest
Re: poll() and select()
« Reply #13 on: June 25, 2017, 11:56:04 am »