OS2 World Community Forum

OS/2, eCS & ArcaOS - Technical => Programming => Topic started by: Jochen Schäfer on June 23, 2017, 09:58:10 pm

Title: poll() and select()
Post by: Jochen Schäfer 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?
Title: Re: poll() and select()
Post by: Valery Sedletski on June 23, 2017, 10:41:17 pm
OS/2 implementation of select() supports sockets, only. Not files.
Title: Re: poll() and select()
Post by: Jochen Schäfer on June 23, 2017, 10:52:37 pm
That explains a lot.
Do we have an OS/2 API for something like this?
Title: Re: poll() and select()
Post by: Valery Sedletski 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 (http://www.edm2.com/index.php/OS2_API:CPI:DosWaitMuxWaitSem) on a set of those semaphores, for example. Or, create your own select/poll implementation supporting files under the hood.
Title: Re: poll() and select()
Post by: Martin Iturbide 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 (http://www.edm2.com/index.php/The_OS/2_API_Project), 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
Title: Re: poll() and select()
Post by: Dave Yeo 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
Title: Re: poll() and select()
Post by: Jochen Schäfer 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.
Title: Re: poll() and select()
Post by: Dave Yeo 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 (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.
Title: Re: poll() and select()
Post by: Jochen Schäfer 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.
Title: Re: poll() and select()
Post by: Paul Smedley 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
Title: Re: poll() and select()
Post by: Herwig Bauernfeind 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.
Title: Re: poll() and select()
Post by: Jochen Schäfer 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.
Title: Re: poll() and select()
Post by: Jochen Schäfer 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?
Title: Re: poll() and select()
Post by: André Heldoorn on June 25, 2017, 11:56:04 am
I suggest to talk to Dmitriy Kuminov about the implementation in libcx.
How?

In English (http://www.os2world.com/forum/index.php?action=pm;sa=send;u=406)?