Discussion:
emx select() with new handles
Sebastian Wittmeier
2004-11-05 14:15:49 UTC
Permalink
Hi,
working on Everblue I encountered a problem.
The existing X11 applications (linked against good old emx) use
select() to wait for events.
My X11.dll opens a named pipe to get a file handle. When I compile
X11.dll with emx, everything is fine. But when I use Innotek gcc, errno
9 (EBADF, Bad file number) arises on select(). Looking quickly through
the source, I believe, the problem is that the new file handle is not
registered in the handle_flags array of emx.dll, when opening the file
with Innotek gcc.

So how can I create valid file handles in an Innotek dll linked against
an emx dll? The only one working seem to be standard in/out/err.

Has anybody compiled XFree86/2 with Innotek GCC yet? And Encountered
the same incompatibilities?

Sebastian
Frank Gießler
2004-11-05 15:21:22 UTC
Permalink
Post by Sebastian Wittmeier
Hi,
working on Everblue I encountered a problem.
The existing X11 applications (linked against good old emx) use
select() to wait for events.
My X11.dll opens a named pipe to get a file handle. When I compile
X11.dll with emx, everything is fine. But when I use Innotek gcc, errno
9 (EBADF, Bad file number) arises on select(). Looking quickly through
the source, I believe, the problem is that the new file handle is not
registered in the handle_flags array of emx.dll, when opening the file
with Innotek gcc.
Sounds like Innotek's select() doesn't support pipes.
Post by Sebastian Wittmeier
Has anybody compiled XFree86/2 with Innotek GCC yet? And Encountered
the same incompatibilities?
AFAIK, to use Innotek gcc for XFree86, it should (at least) treat

pipes
PTYs
sockets

just like ordinary file handles (you can use open(), read(), write(),
etc. on them). But maybe I'm wrong?

Regards,
Frank.
--
Frank Giessler
Klinikum der Universitaet Jena Tel.: +49-3641-9 32 57 80
Biomagnetisches Zentrum Fax : +49-3641-9 32 57 72
Dave Yeo
2004-11-05 15:50:53 UTC
Permalink
Post by Sebastian Wittmeier
Hi,
working on Everblue I encountered a problem.
The existing X11 applications (linked against good old emx) use
select() to wait for events.
My X11.dll opens a named pipe to get a file handle. When I compile
X11.dll with emx, everything is fine. But when I use Innotek gcc, errno
9 (EBADF, Bad file number) arises on select(). Looking quickly through
the source, I believe, the problem is that the new file handle is not
registered in the handle_flags array of emx.dll, when opening the file
with Innotek gcc.
So how can I create valid file handles in an Innotek dll linked against
an emx dll? The only one working seem to be standard in/out/err.
Has anybody compiled XFree86/2 with Innotek GCC yet? And Encountered
the same incompatibilities?
Sebastian
This is what Knut had to say last year

This shouldn't be surprising to anyone which read the release notes and
have followed some of the mails here. LIBC is at the moment using OS/2
socket handles untranslated. So, since there is like 32k sockets in the
BSD 4.4 based stack, you might get somewhat higher socket handles than
what BSD select would normally work with.
And even if you were lucky and got a few low socket numbers it still
wouldn't work since select() is called. LIBC select is at the moment not
doing much. bsdselect() and os2_select() might be tried instead.

I've built Blackbox with Innoteks GCC. the problems were, not getting the display. This problem was also inherited by any apps that were started by blackbox. Erratic mouse behaviour, mostly shown by menus not opening on mouse over.
Dave
Sebastian Wittmeier
2004-11-06 01:43:18 UTC
Permalink
Hi Dave,
Post by Dave Yeo
This is what Knut had to say last year
This shouldn't be surprising to anyone which read the release notes and
have followed some of the mails here. LIBC is at the moment using OS/2
socket handles untranslated. So, since there is like 32k sockets in the
BSD 4.4 based stack, you might get somewhat higher socket handles than
what BSD select would normally work with.
And even if you were lucky and got a few low socket numbers it still
wouldn't work since select() is called. LIBC select is at the moment not
doing much. bsdselect() and os2_select() might be tried instead.
I've built Blackbox with Innoteks GCC. the problems were, not getting the display. This problem was also inherited by any apps that were started by blackbox. Erratic mouse behaviour, mostly shown by menus not opening on mouse over.
Dave
It is more a problem with emx. I call the emx select() with a file
opened by Innotek open().
The Innotek open() gives an OS/2 file handle, but does not update emx
internal information about open file handles.
So emx select() does not recognize the handle.

If that problem persists, XFree86/2 will never be compatible with both
emx and Ilibc programs, but only with the kind itself is linked
against.

Sebastian
Sebastian Wittmeier
2004-11-05 16:06:37 UTC
Permalink
Post by Frank Gießler
Sounds like Innotek's select() doesn't support pipes.
I tried: The problem is also with normal files.
And it is emx's select() - I open with Innotek dll and select with emx
exe.
Post by Frank Gießler
Post by Sebastian Wittmeier
So how can I create valid file handles in an Innotek dll linked against
an emx dll? The only one working seem to be standard in/out/err.
Has anybody compiled XFree86/2 with Innotek GCC yet? And Encountered
the same incompatibilities?
Sebastian
AFAIK, to use Innotek gcc for XFree86, it should (at least) treat
pipes
PTYs
sockets
just like ordinary file handles (you can use open(), read(), write(),
etc. on them). But maybe I'm wrong?
Regards,
Frank.
As far as I read the newest Innotek alpha has some improvements. But it
has timebombed already.

Sebastian
Andy Willis
2004-11-05 17:11:29 UTC
Permalink
Post by Sebastian Wittmeier
As far as I read the newest Innotek alpha has some improvements. But it
has timebombed already.
I spoke to Knut at Warpstock about this and he said that there were no
impovements in the Alpha yet anyway. He said that he would look at it
but seemed doubtful that it would make it into 3.3.4 as he had to many
commitments. He said he hoped to see you at Warpstock Europe and have a
chance to speak to you.
Andy
Sebastian Wittmeier
2004-11-07 00:49:27 UTC
Permalink
Post by Andy Willis
I spoke to Knut at Warpstock about this and he said that there were no
impovements in the Alpha yet anyway. He said that he would look at it
but seemed doubtful that it would make it into 3.3.4 as he had to many
commitments. He said he hoped to see you at Warpstock Europe and have a
chance to speak to you.
Andy
I'll be there, of course. And sure there will be time for some talk ...

Sebastian
Sebastian Wittmeier
2004-11-06 01:36:59 UTC
Permalink
Hi Knut,
The first problem is that it's not a socket. But that should give you a
EINVAL according to the code, so something else is broken. Come to think
of it I haven't subjected LIBC to any named pipe handles yet, I'll give
it a shot when I get home.
Current LIBC doesn't support select() on anything but sockets. Nuke said
he had some ideas about this 6 months ago, but I haven't gotten any code
from him yet (and I don't blame him knowing that he's been extermely
busy with real world stuff).
Actually for named pipes there are peeking functions IIRC, so it
shouldn't be too hard to select them. I'll try find time to do that for
the next (not the first) LIBC release.
Thank you for your reply. My message was a bit mistakable.
The problem is that when open()ing a file with Innotek gcc, it cannot
be selected with emx select().

I'm working with OS/2 file handles. The problem even arises with normal
files (not named pipes).
The (probable) explanation is, emx open() takes some notes about open
file handles. Innotek open() does not take these notes. Therefore file
handles cannot be exchanged. I suspect the handle_flags array to be the
culprit, where emx stores the relevant information.
LIBC and EMX can use the same OS/2 filehandles, but they might easily
have different opinions about them and get confused. Sending file
streams (FILE, stdio.h) does not work.
So
- is it possible to share opinions between emx and libc?
- should we patch emx.dll for better cooperation?
- does every program which is involved in sharing handles (like every
X11 program) have to be recompiled?
Kind Regards,
knut
Sebastian
S***@t-online.de
2004-11-06 22:55:49 UTC
Permalink
Addressed to: os2-***@mail.warpix.org
"***@xfreeos2.dyndns.org" <***@xfreeos2.dyndns.org>

Hi,
Post by Sebastian Wittmeier
Has anybody compiled XFree86/2 with Innotek GCC yet? And Encountered
the same incompatibilities?
Actually, I tried compiling XFree86 4.4.0 and the build process crashed
right in it's first call to the freshly compiled xmkmf, same as sombody
reported for the other branch of X developpment.
Since there's no working gdb for Innotek's compiler, that's where
I have to stop all efforts... :-(

Regards,
Stefan
Sebastian Wittmeier
2004-11-07 00:39:05 UTC
Permalink
ISTM the EMX _imphandle() and _impsockhandle() routines are intended for
dealing with these sorts of issues.
Thank you! That will help ...
So I will use emx AND libc at the same time. Are there any problems to
expect?
I would create another support DLL that imports EMX _imphandle() and
calls it with the handle returned by Innotek open().

Sebastian
Sebastian Wittmeier
2004-11-07 15:32:46 UTC
Permalink
ISTM the EMX _imphandle() and _impsockhandle() routines are intended for
dealing with these sorts of issues.
It works! Thank you everybody for your help.

Sebastian

Loading...