I tried to port mksh to Coherent, and I hit some issues:
- there is no gettimeofday() and I used time() instead
- there is no termios.h and I tried to use termio.h instead (for
tcgetattr() and tcsetattr())
- there is no tcgetpgrp() and tcsetpgrp() so I disabled job control
- there is no lstat() and readlink(), I used stat() and failing the
readlink() line
- the Build.sh script cannot generate a list of signals because it
seems that sed fails to print the tab char (0x9). I tried gnu sed 2.05
too but the problem still (both 2.03 and 2.05 works in other platform,
so I think it is a bug in Coherent 4.2.10 kernel)
- for workarounding the above issue, I removed the sed line and make
use of gawk to get a list. It successfully got some of them, and then
I got "Build.sh: line 1824: Unable to preserve redirection state when
redirecting builtin" and "grep: (standard input): bad file number"
- Signals are broken (build with -DMKSH_UNEMPLOYED(for disabling job
controls) but not -DMKSH_NOPROSPECTOFWORK, it will generate binary,
but when you run external command like "ls", it will never return to
shell prompt. actually bash-1.13 coherent port is also affected which
fails to get correct exit status from gcc in Build.sh) but with -
DMKSH_NOPROSPECTOFWORK it works. (Note that this option produces a
shell not supporting standard Korn Shell scripts.)
In general , You will find a lot of missing functions in glibc. Download glibc sources and try to port missing functions. It is one of my favourite methods when I port something. If something is missing I look in glibc first.
> - there is no lstat() and readlink(), I used stat() and failing the
> readlink() line
It is obvious, coherent does not support symbolic links
> I tried to port mksh to Coherent, and I hit some issues:
> - there is no gettimeofday() and I used time() instead
> - there is no termios.h and I tried to use termio.h instead (for
> tcgetattr() and tcsetattr())
> - there is no tcgetpgrp() and tcsetpgrp() so I disabled job control
> - there is no lstat() and readlink(), I used stat() and failing the
> readlink() line
> I tried to port mksh to Coherent, and I hit some issues:
> - there is no gettimeofday() and I used time() instead
> - there is no termios.h and I tried to use termio.h instead (for
> In general , You will find a lot of missing functions in glibc. Download
> glibc sources and try to port missing functions. It is one of my
> favourite methods when I port something. If something is missing I look
> in glibc first.
Tried, the main problem is the signal one. I can see that bash-1.13.5
and mksh are affected.
> On Apr 26, 2:13 pm, andrzej Popielewicz<va...@icpnet.pl> wrote:
>> gettimeofday can be found in libsocket.a , available in coherent
>> internet archives
> I can't get libsocket compiling in 4.2.10, it complains there is no
> NOFILE defined.
As far as I remember I also had problems with compiling libsocket. Finally it compiled but did not work as original compiled version. So I am using original libsocket.a .
NOFILE should be defined somewhere in the /usr/include .If not find it in include files of glibc or define it Yourself.It is the maksimum number of opened files,I suspect number about of order of 64 (?) it must be somewhere in /usr/include, perhaps with slightly changed name. The location of include files in Coherent does not have to be same as in glibc world.
> Tried, the main problem is the signal one. I can see that bash-1.13.5
> and mksh are affected.
There is also original bash version in the archives.Did You try this ?
It dose not mean signal system in Coherent is perfect. Many features are missing .
As far as I know the option You use in mksh can allow to track signal bugs. Try to locate where the bugs happen and what is their nature.
> > On Apr 26, 2:13 pm, andrzej Popielewicz<va...@icpnet.pl> wrote:
> >> gettimeofday can be found in libsocket.a , available in coherent
> >> internet archives
> > I can't get libsocket compiling in 4.2.10, it complains there is no
> > NOFILE defined.
> As far as I remember I also had problems with compiling libsocket.
> Finally it compiled but did not work as original compiled version. So I
> am using original libsocket.a .
> NOFILE should be defined somewhere in the /usr/include .If not find it
> in include files of glibc or define it Yourself.It is the maksimum
> number of opened files,I suspect number about of order of 64 (?) it
> must be somewhere in /usr/include, perhaps with slightly changed name.
> The location of include files in Coherent does not have to be same as in
> glibc world.
> > Tried, the main problem is the signal one. I can see that bash-1.13.5
> > and mksh are affected.
> There is also original bash version in the archives.Did You try this ?
I used the bash-1.13.5.tgz in gopher://telefisk.org/1/coherent/sources32/system/
I can see bash fails the same as bash in BeOS 5.0 (Build.sh exits
after "if the compiler does not fail correctly... no")
> It dose not mean signal system in Coherent is perfect. Many features are
> missing .
> As far as I know the option You use in mksh can allow to track signal
> bugs. Try to locate where the bugs happen and what is their nature.
On Apr 26, 11:10 am, Roy <roy...@gmail.com> wrote:
> - Signals are broken (build with -DMKSH_UNEMPLOYED(for disabling job
> controls) but not -DMKSH_NOPROSPECTOFWORK, it will generate binary,
> but when you run external command like "ls", it will never return to
> shell prompt. actually bash-1.13 coherent port is also affected which
> fails to get correct exit status from gcc in Build.sh) but with -
> DMKSH_NOPROSPECTOFWORK it works. (Note that this option produces a
> shell not supporting standard Korn Shell scripts.)
In ps -alx, it shows that mksh is idle-waiting sigsuspend, so that's
the problem."that is a hint that mksh never gets the SIGCHLD, see also
http://dev.haiku-os.org/ticket/5567, Haiku had the same problem, but
fixed it" said tg.
On Apr 27, 1:56 pm, andrzej Popielewicz <va...@icpnet.pl> wrote:
> W dniu 2012-04-27 03:46, Roy pisze:
> > In ps -alx, it shows that mksh is idle-waiting sigsuspend, so that's
> OK, it is precise enough I hope to try to fix it. I will look at it.
> Thanks for the valuable signal.
> Andrzej
I wonder if sigsuspend() should be same as sigprocmask(SIG_SETMASK,
&set, &oset); pause(); sigprocmask(SIG_SETMASK, &oset, NULL); ?
I don't know why sigsuspend() is broken in BeOS 5.0 and Coherent.
> I wonder if sigsuspend() should be same as sigprocmask(SIG_SETMASK,
In Coherent it should have the same result.
But returning to the main problem . I assume that You suspect that sigsuspend is broken. Well, so far as I can estimate this signal handling in Coherent is quite well compatible with SYSV and Posix standards.
You mentioned similar problem in other OS, which was fixed. This fixed problem concerns threads and Coherent does not have threads and "translating" this fix to processes is not quite obvious if at all making sense.
I have analysed Your package. I could build mksh using gcc-2.8.1 and gcc-3.2.3 and I did not notice any problems with sigsuspend. I did NOT use Your option D_NOPROSPECTFORWORK nor D_NOEMPLOYED. I have removed this option from Your mk.sh. I have added LDFLAGS="-L/usr/lib -lsocket -lcoh -L/lib/ndp -lc -lm" , where libcoh.a is my own library of utility functions and libsocket.a is original from mwc. I have have removed option -DUSE_TERMIO.
Unfortunalety mksh built in such a way does not work. I observe the message
internal error, roque pointer 8C8 !!!
Never seen such message, although I have ported hundreds of packages.
BTW , the same meesage is produced if I use Your option -D_NOPROSPECTS...
Concluding I do not think the problem is related to sigsuspend, of course I may be wrong.
BTW , the missing functions like lstat, readlink . tcgpgrp, etc I have supplied in the form of wrappers, for example my lstat uses stat , readlink returns -1 and errno is set to EINVAL etc. This method is oft used, because You do not have to change the original source code.
> On Apr 27, 1:56 pm, andrzej Popielewicz <va...@icpnet.pl> wrote:
>> W dniu 2012-04-27 03:46, Roy pisze:
> I wonder if sigsuspend() should be same as sigprocmask(SIG_SETMASK,
Read this from Linux man, it concerns also Coherent
I would suggest , that mksh has internal problems with memory access.
Something tries to write to the memory range allocated by malloc and this write operation is in some way not correct, for example exceeds the allowed range of memory addresses.
One should look in other words for memory corruption, buffer overflow etc, I suspect.Sometimes last byte of character string euqal to '\0' is written to the memory address , which was not allocated, the allocated storage was one byte too short etc, just to mention an example..
> > I wonder if sigsuspend() should be same as sigprocmask(SIG_SETMASK,
> In Coherent it should have the same result.
> But returning to the main problem . I assume that You suspect that
> sigsuspend is broken. Well, so far as I can estimate this signal
> handling in Coherent is quite well compatible with SYSV and Posix
> standards.
> You mentioned similar problem in other OS, which was fixed. This fixed
> problem concerns threads and Coherent does not have threads and
> "translating" this fix to processes is not quite obvious if at all
> making sense.
> I have analysed Your package. I could build mksh using gcc-2.8.1 and
> gcc-3.2.3 and I did not notice any problems with sigsuspend. I did NOT
> use Your option D_NOPROSPECTFORWORK nor D_NOEMPLOYED. I have removed
> this option from Your mk.sh. I have added LDFLAGS="-L/usr/lib -lsocket
> -lcoh -L/lib/ndp -lc -lm" , where libcoh.a is my own library of utility
> functions and libsocket.a is original from mwc. I have have removed
> option -DUSE_TERMIO.
please release gcc-2.8.1 and gcc-3.2.3 binary packages for testing.
I'm using gcc-2.5.6 from gnu[1234].c.c++.dd, with ld.pre11 as /bin/ld
-DMKSH_UNEMPLOYED is needed if OS doesn't support tc[gs]etpgrp()
calls.
> Unfortunalety mksh built in such a way does not work. I observe the message
> internal error, roque pointer 8C8 !!!
> Never seen such message, although I have ported hundreds of packages.
> BTW , the same meesage is produced if I use Your option -D_NOPROSPECTS...
> Concluding I do not think the problem is related to sigsuspend, of
> course I may be wrong.
> BTW , the missing functions like lstat, readlink . tcgpgrp, etc I have
> supplied in the form of wrappers, for example my lstat uses stat ,
> readlink returns -1 and errno is set to EINVAL etc. This method is oft
> used, because You do not have to change the original source code.
"failing" tc[gs]etpgrp() cannot fool mksh for having jobs control.
pdksh in coherent has no jobs control compiled.
> > I wonder if sigsuspend() should be same as sigprocmask(SIG_SETMASK,
> In Coherent it should have the same result.
> But returning to the main problem . I assume that You suspect that
> sigsuspend is broken. Well, so far as I can estimate this signal
> handling in Coherent is quite well compatible with SYSV and Posix
> standards.
> You mentioned similar problem in other OS, which was fixed. This fixed
> problem concerns threads and Coherent does not have threads and
> "translating" this fix to processes is not quite obvious if at all
> making sense.
> I have analysed Your package. I could build mksh using gcc-2.8.1 and
> gcc-3.2.3 and I did not notice any problems with sigsuspend. I did NOT
> use Your option D_NOPROSPECTFORWORK nor D_NOEMPLOYED. I have removed
> this option from Your mk.sh. I have added LDFLAGS="-L/usr/lib -lsocket
> -lcoh -L/lib/ndp -lc -lm" , where libcoh.a is my own library of utility
> functions and libsocket.a is original from mwc. I have have removed
> option -DUSE_TERMIO.
> Unfortunalety mksh built in such a way does not work. I observe the message
> internal error, roque pointer 8C8 !!!
> Never seen such message, although I have ported hundreds of packages.
> BTW , the same meesage is produced if I use Your option -D_NOPROSPECTS...
> Concluding I do not think the problem is related to sigsuspend, of
> course I may be wrong.
> BTW , the missing functions like lstat, readlink . tcgpgrp, etc I have
> supplied in the form of wrappers, for example my lstat uses stat ,
> readlink returns -1 and errno is set to EINVAL etc. This method is oft
> used, because You do not have to change the original source code.
> Andrzej
and you may redownload mksh-coh.tgz which is based on author's
internal version having #ifdef for using sigprocmask()+pause()
+sigprocmask() instead of sigsuspend(), which works in Coherent/
Syllable Desktop/BeOS 5.0.
in original code, sigsuspend(&sm_default) and sm_default is set by
sigemptyset(), that means sigsuspend() should return when any signal
is raised (child exit should raise SIGCLD), but sigsuspend() doesn't
return and pause() does return. "so it(mksh)'s definitely a check tool
for kernel bugs" said by tg(author of mksh).
> On Apr 30, 1:14 am, Andrzej Popielewicz <va...@icpnet.pl> wrote:
> > Roy pisze:
> > > I wonder if sigsuspend() should be same as sigprocmask(SIG_SETMASK,
> > In Coherent it should have the same result.
> > But returning to the main problem . I assume that You suspect that
> > sigsuspend is broken. Well, so far as I can estimate this signal
> > handling in Coherent is quite well compatible with SYSV and Posix
> > standards.
> > You mentioned similar problem in other OS, which was fixed. This fixed
> > problem concerns threads and Coherent does not have threads and
> > "translating" this fix to processes is not quite obvious if at all
> > making sense.
> > I have analysed Your package. I could build mksh using gcc-2.8.1 and
> > gcc-3.2.3 and I did not notice any problems with sigsuspend. I did NOT
> > use Your option D_NOPROSPECTFORWORK nor D_NOEMPLOYED. I have removed
> > this option from Your mk.sh. I have added LDFLAGS="-L/usr/lib -lsocket
> > -lcoh -L/lib/ndp -lc -lm" , where libcoh.a is my own library of utility
> > functions and libsocket.a is original from mwc. I have have removed
> > option -DUSE_TERMIO.
> please release gcc-2.8.1 and gcc-3.2.3 binary packages for testing.
> I'm using gcc-2.5.6 from gnu[1234].c.c++.dd, with ld.pre11 as /bin/ld
> -DMKSH_UNEMPLOYED is needed if OS doesn't support tc[gs]etpgrp()
> calls.
> > Unfortunalety mksh built in such a way does not work. I observe the message
> > internal error, roque pointer 8C8 !!!
> > Never seen such message, although I have ported hundreds of packages.
> > BTW , the same meesage is produced if I use Your option -D_NOPROSPECTS...
> > Concluding I do not think the problem is related to sigsuspend, of
> > course I may be wrong.
> > BTW , the missing functions like lstat, readlink . tcgpgrp, etc I have
> > supplied in the form of wrappers, for example my lstat uses stat ,
> > readlink returns -1 and errno is set to EINVAL etc. This method is oft
> > used, because You do not have to change the original source code.
> "failing" tc[gs]etpgrp() cannot fool mksh for having jobs control.
> pdksh in coherent has no jobs control compiled.
> On Apr 30, 1:14 am, Andrzej Popielewicz <va...@icpnet.pl> wrote:
> > Roy pisze:
> > > I wonder if sigsuspend() should be same as sigprocmask(SIG_SETMASK,
> > In Coherent it should have the same result.
> > But returning to the main problem . I assume that You suspect that
> > sigsuspend is broken. Well, so far as I can estimate this signal
> > handling in Coherent is quite well compatible with SYSV and Posix
> > standards.
> > You mentioned similar problem in other OS, which was fixed. This fixed
> > problem concerns threads and Coherent does not have threads and
> > "translating" this fix to processes is not quite obvious if at all
> > making sense.
> > I have analysed Your package. I could build mksh using gcc-2.8.1 and
> > gcc-3.2.3 and I did not notice any problems with sigsuspend. I did NOT
> > use Your option D_NOPROSPECTFORWORK nor D_NOEMPLOYED. I have removed
> > this option from Your mk.sh. I have added LDFLAGS="-L/usr/lib -lsocket
> > -lcoh -L/lib/ndp -lc -lm" , where libcoh.a is my own library of utility
> > functions and libsocket.a is original from mwc. I have have removed
> > option -DUSE_TERMIO.
> > Unfortunalety mksh built in such a way does not work. I observe the message
> > internal error, roque pointer 8C8 !!!
> > Never seen such message, although I have ported hundreds of packages.
> > BTW , the same meesage is produced if I use Your option -D_NOPROSPECTS...
> > Concluding I do not think the problem is related to sigsuspend, of
> > course I may be wrong.
> > BTW , the missing functions like lstat, readlink . tcgpgrp, etc I have
> > supplied in the form of wrappers, for example my lstat uses stat ,
> > readlink returns -1 and errno is set to EINVAL etc. This method is oft
> > used, because You do not have to change the original source code.
> > Andrzej
> and you may redownload mksh-coh.tgz which is based on author's
> internal version having #ifdef for using sigprocmask()+pause()
> +sigprocmask() instead of sigsuspend(), which works in Coherent/
> Syllable Desktop/BeOS 5.0.
forgot to mention: Build.sh in this package requires GNU grep in name
"ggrep" because Coherent grep doesn't seem to work with the search
criteria that Build.sh uses.
> in original code, sigsuspend(&sm_default) and sm_default is set by
> sigemptyset(), that means sigsuspend() should return when any signal
> is raised (child exit should raise SIGCLD), but sigsuspend() doesn't
> return and pause() does return. "so it(mksh)'s definitely a check tool
> for kernel bugs" said by tg(author of mksh).
> please release gcc-2.8.1 and gcc-3.2.3 binary packages for testing.
> I'm using gcc-2.5.6 from gnu[1234].c.c++.dd, with ld.pre11 as /bin/ld
As I told many times, I will release almost everything , for example in the form of CD or DVD image, after Robert is ready with his OpenCoherent license. On the other hand I could imagine thousands of questions, as I can see in this small case.
I have about 20 GB if not more of different versions of different packages.
And I am not going to make any choice. Just release everything.
Other problem, there is no warranty it will work in standard Coherent. I would have to test it before and it all costs time and hardware.And I am not planning for sure to test it if it works in emulator etc etc. Not so easy.
> -DMKSH_UNEMPLOYED is needed if OS doesn't support tc[gs]etpgrp()
I understand. But You can write Your own dummy routines, as I mentioned in my post.They will return -1.
But the code will be linkable and You can always add real life into these functions later.
> not found in mksh source, this should be message from kernel/libc.
> and I haven't seen this in my binary. (although I'm using your
> 4.2.10ap 128MB-enabled kernel)
Yes, of course, I did not claim its is a message produced by mksh. But the message suggests the nature of problems the system has with running this program, it means program does something which is not acceptable for the system.
But generally the phenomennon is not quite new, I had such cases. Program linked but it did not work, for example crashed or even said "cannot execute". Sometimes solution was found and sometimes not. I am not dye-hard porter, if something does not work I leave it and take another project, after some time I come back and perhaps solution is found.
What is interesting if I use gcc-4.4.6, the mksh does not produce this message but the program loops, in the sense, that it consumes CPU time, as observed on other terminal and the system is very slow. But gcc-4.4.6 is rather an experimental and I have more confidence in gcc-2.8.1 and gcc-3.2.3.
> (I created a wrapper for /bin/ln faking symbolic links, therefore cd-
> pe test have to be disabled because of recursive directory loop)
I use also this trick in my system.Sometimes "ln" is simply a "cp".
> "failing" tc[gs]etpgrp() cannot fool mksh for having jobs control.
> pdksh in coherent has no jobs control compiled.
Yes. But I have also implemented these functions. In any case in both cases , real or dummy functions ,effects are the same.
> On Apr 30, 1:14 am, Andrzej Popielewicz<va...@icpnet.pl> wrote:
>> Roy pisze:
> and you may redownload mksh-coh.tgz which is based on author's
> internal version having #ifdef for using sigprocmask()+pause()
> +sigprocmask() instead of sigsuspend(), which works in Coherent/
> Syllable Desktop/BeOS 5.0.
OK, I will check it.
> in original code, sigsuspend(&sm_default) and sm_default is set by
> sigemptyset(), that means sigsuspend() should return when any signal
> is raised (child exit should raise SIGCLD), but sigsuspend() doesn't
> return and pause() does return. "so it(mksh)'s definitely a check tool
> for kernel bugs" said by tg(author of mksh).
Not so fast. If something does not work it does not mean kernel is bad. In 99% such cases usually there is program which is wrong.
If sigsuspend is not returning in the case of SIGCHLD signal, it means there were no signal handler defined for SIGCHLD. You can write simple program, with and without signal handler defined.If child sends SIGCHLD signal, waitpid always will "detect" this, it means will return with -1 and EINTR error. I have tested it, so I assume Coherent kernel behaves correctly , at least as I can understand this now.
So You have to analyse whether in the case You use sigsuspend , the signal handler for SIGCHLD is active, I mean explictly defined with no SIG_IGN or SIG_DFL.
The default behaviour of Coherent kernel is to ignore SIGCHLD, but only in the case of SIG_IGN or SIG_DFL action.If signal handler is explictly defined with nontrivial action, signal is not ignored and waitpid detects it.
> On Apr 30, 1:14 am, Andrzej Popielewicz<va...@icpnet.pl> wrote:
>> Roy pisze:
> and you may redownload mksh-coh.tgz which is based on author's
> internal version having #ifdef for using sigprocmask()+pause()
> +sigprocmask() instead of sigsuspend(), which works in Coherent/
> Syllable Desktop/BeOS 5.0.
So You suggest, that in this case mksh behaves OK ?
As I said I will check it. Logically this construction is handled by Coherent kernel in the same way as sigsuspend. Although there are some technical differences.
If this case is really working I will try to fix sigsuspend correspondingly simply by removing these differences.
Obvious difference is that sigsuspend is more "atomic", it is one system call. And above construction consists of 3 system calls.This difference cannot be removed.
W dniu 2012-04-30 08:55, andrzej Popielewicz pisze:
> W dniu 2012-04-30 04:45, Roy pisze:
> You can write simple
> program, with and without signal handler defined.If child sends SIGCHLD
> signal, waitpid always will "detect" this, it means will return with -1
> and EINTR error. I have tested it, so I assume Coherent kernel behaves
> correctly , at least as I can understand this now.
Of course waitpid will detect this SIGCHLD signal if signal handler is explicitly defined , and wil NOT detect if signal handler is not defined. By defined handler I mean not only signal statement or sigaction statement. But also the function body of the handler.
An the handler body can be empty, it is enough that it does exist, is not NULL.
Sometimes one uses wait or waitpid in the handlers body.