Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the board
Thread view  Mix view  Order
roytam(R)

23.12.2011, 02:45
 

mksh (Rugxulo, please come in!) (Miscellaneous)

Rugxulo: "13:47 < Rugxulo> disable job control (MKSH_UNEMPLOYED, maybe MKSH_NOPROSPECTOFWORK ?? I did that part manually) and it builds"

I did it a month ago on native DJGPP. ;-)
[2011-11-21 18:55] <RT|Chatzilla> OK back home. Updated DJGPP libraries and added missing awk and grep: http://www.mediafire.com/file/l2kbiibm1bdai8b/djgpp204.7z log: http://pastebin.com/7RJSV16e diff: http://pastebin.com/yq6BHL5A

--- Log opened Tue Nov 22 00:00:15 2011
08:55 < RT|work> Just found that DJGPP's fork() doesn't working. How can I make mksh working without fork() call?
18:36 < mira|AO> it?s impossible to make a full POSIX shell without fork()
18:39 < mira|AO> mh, wow. bash segfaulted for me.
18:40 < mira|AO> but without a working fork, you have almost no chance
18:40 < mira|AO> I think the fork emulation puts all global variables into a struct, uses a pointer to access it and threads, or somesuch
18:40 < mira|AO> that won't work on DOS either
18:40 < RT|Chatzilla> Yes. I wonder which ksh will work on DJGPP.
18:46 < mira|AO> without fork, you cannot get one.
18:48 < mira|AO> think: (foo | (BAR=baz blah; blub) | meow) |& while read -p line; do ?
18:48 < mira|AO> you cannot do all that with spawn()
18:49 < RT|Chatzilla> so DJGPP users have to use DJGPP's bash. IIRC DJGPP gawk uses temporary files for the subprocess pipes.
18:49 < mira|AO> at the moment, i'd say so
18:49 < mira|AO> but once we integrate most of the winapi port, someone can have a look at djgpp again
18:54 < RT|Chatzilla> <mira|AO> mh, wow. bash segfaulted for me. # from my testing, DJGPP bash 2.04b/2.05b can run Build.sh (under Windows XP, I haven't test it under Real DOS)
18:55 < mira|AO> i don't remember where i tested
18:56 < mira|AO> probably under win2k
18:56 < mira|AO> possibly real dos, too
18:56 < mira|AO> might have been both

Rugxulo(R)

Homepage

Usono,
23.12.2011, 08:10

@ roytam

mksh (ENOMEM, ENOCARE)

Hi,

> Rugxulo: "13:47 < Rugxulo> disable job control (MKSH_UNEMPLOYED, maybe
> MKSH_NOPROSPECTOFWORK ?? I did that part manually) and it builds"
>
> I did it a month ago on native DJGPP. ;-)

I'm honestly not sure why I even bothered. Sometimes I think, "I wonder if xyz will work" and run off to compile it. I was probably just buoyed by my own success at Ruby and (re)discovering that damn NUL bug in DOSEMU (actually, FreeDOS). DJGPP's Bash (2.04 or 2.05b) is just too old and buggy, so I sometimes wonder if something simpler could ever replace it.

Oh, and BTW, I wouldn't have publicly mentioned it at all except they (he?) seems "almost" sympathetic to DOS (also see JUPP 2.8's DOS version):

https://www.mirbsd.org/mksh.htm


OS: MS-DOS, DR DOS, FreeDOS

DJGPP?s bash.exe fails to run Build.sh, thus this is currently not supported. (We tried!)

Future Plans

Build and actually work on more platforms ? DJGPP, PW32, Plan 9, Syllable ? debug these


I just used Ozkan's cross compiler (3.4.6) atop PuppyLinux (for once, for simplicity).

> --- Log opened Tue Nov 22 00:00:15 2011
> 08:55 < RT|work> Just found that DJGPP's fork() doesn't working. How can I
> make mksh working without fork() call?

It returns -1 and ENOMEM, I think. I don't know if DJ thought that would trigger a fallback in most people's code or not. It's kinda sad, IMO, that people can't live without it in their code.

> 18:36 < mira|AO> it?s impossible to make a full POSIX shell without fork()

I don't know if that's true. Bash doesn't use fork() at all, and it works. Granted, you basically doing everything sequentially, but it (more or less) works, at least for our primary usage, to run ./configure.

I'm not knowledgeable about fork/exec at all, but I did (weakly) patch m2c recently to not need it so that it would work in DOS with DJGPP.

> 18:39 < mira|AO> mh, wow. bash segfaulted for me.

That's no surprise, but it would be VERY nice to know what Bash version and DOS-based environment he ran it in.

> 18:40 < mira|AO> but without a working fork, you have almost no chance
> 18:40 < mira|AO> I think the fork emulation puts all global variables into
> a struct, uses a pointer to access it and threads, or somesuch
> 18:40 < mira|AO> that won't work on DOS either

At worst, it "could" work in DR-DOS, RDOS, or some such. At best, it would work everywhere. We do have various threading packages (cooperative, mostly) that work, if that's the case, but I doubt it would help here.

> 18:40 < RT|Chatzilla> Yes. I wonder which ksh will work on DJGPP.
> 18:46 < mira|AO> without fork, you cannot get one.

There were some old shells (semi)"ported" to DOS + OS/2 via EMX used by OS/2 Perl. That was pdksh too, IIRC, which mksh is based upon. Now, they didn't work very well for me (probably due to my inexperience), so I never used them much, but they do exist. (Yes, the OS/2 Perl was at one time suggested for DOS too.)

http://math.berkeley.edu/~ilya/software/os2/

> 18:48 < mira|AO> think: (foo | (BAR=baz blah; blub) | meow) |& while read
> -p line; do ?
> 18:48 < mira|AO> you cannot do all that with spawn()

Unless you "need" two things to happen at the same time, then it doesn't matter. Just because you want two different programs to run independently doesn't mean they have to be concurrent.

> 18:49 < RT|Chatzilla> so DJGPP users have to use DJGPP's bash. IIRC DJGPP
> gawk uses temporary files for the subprocess pipes.

Yes, popen() and friends (IIRC) do indeed use temporary files. There's probably a better way (DPMI 1.0 0x508 ??), but so far nobody's cared to mess with it.

> 18:49 < mira|AO> at the moment, i'd say so
> 18:49 < mira|AO> but once we integrate most of the winapi port, someone can
> have a look at djgpp again

Right, because Windows doesn't exactly have fork() either, so Cygwin has to fake it. And if Cygwin can fake it, so can we (I presume)! ;-)

> 18:54 < RT|Chatzilla> <mira|AO> mh, wow. bash segfaulted for me. # from my
> testing, DJGPP bash 2.04b/2.05b can run Build.sh (under Windows XP, I
> haven't test it under Real DOS)
> 18:55 < mira|AO> i don't remember where i tested
> 18:56 < mira|AO> probably under win2k
> 18:56 < mira|AO> possibly real dos, too
> 18:56 < mira|AO> might have been both

Real DOS has issues sometimes, e.g. ./configure (at least for me) doesn't always work. Emulated environments (NTVDM, DOSEMU) seem better for compiling in such circumstances.

Ibidem(R)

05.01.2012, 22:33

@ roytam

mksh (Rugxulo, please come in!)

> Rugxulo: "13:47 < Rugxulo> disable job control (MKSH_UNEMPLOYED, maybe
> MKSH_NOPROSPECTOFWORK ?? I did that part manually) and it builds"
>
> I did it a month ago on native DJGPP. ;-)
> [2011-11-21 18:55] <RT|Chatzilla> OK back home. Updated DJGPP libraries and
> added missing awk and grep:

Great!
FWIW, a port of pdksh is also available:
http://www.ilyaz.org/software/os2/
dos_bin.zip has the one known to run on DOS, but maybe the EMX versions also do...
Also, ack just might be able to compile mksh on DOS--it can on Minix 3.

Rugxulo(R)

Homepage

Usono,
05.01.2012, 23:00

@ Ibidem

mksh (Rugxulo, please come in!)

> > Rugxulo: "13:47 < Rugxulo> disable job control (MKSH_UNEMPLOYED, maybe
> > MKSH_NOPROSPECTOFWORK ?? I did that part manually) and it builds"
> >
> > I did it a month ago on native DJGPP. ;-)
> > [2011-11-21 18:55] <RT|Chatzilla> OK back home. Updated DJGPP libraries
> and
> > added missing awk and grep:
>
> Great!

I think you misunderstood, his only updated his build tools, IIRC. Sure, you can "build" mksh into an .EXE, but it won't "work". ;-)

> FWIW, a port of pdksh is also available:
> http://www.ilyaz.org/software/os2/
> dos_bin.zip has the one known to run on DOS, but maybe the EMX versions
> also do...

But it may only work with EMX, and that barely works on DOS. In other words, it won't replace all the missing POSIX tools, LFNs, long cmdlines, etc. for you, sadly.

> Also, ack just might be able to compile mksh on DOS--it can on Minix 3.

ACK doesn't have a DOS port, does it? Anyways, Minix has fork(), and we don't. So, unless we hack at it and cross our fingers, for now we're stuck with (old) Bash 2.x. As mentioned, we only really "need" it for ./configure, which has its own issues. (DJGPP is probably as good as we can expect, for the foreseeable future.)

Ibidem(R)

08.01.2012, 03:37

@ Rugxulo

mksh (Rugxulo, please come in!)

> > Great!
> I think you misunderstood, his only updated his build tools, IIRC. Sure,
> you can "build" mksh into an .EXE, but it won't "work". ;-)
I did misunderstand.:-(

> > FWIW, a port of pdksh is also available:
> >
> http://www.ilyaz.org/software/os2/
> > dos_bin.zip has the one known to run on DOS, but maybe the EMX versions
> > also do...
>
> But it may only work with EMX, and that barely works on DOS. In other
> words, it won't replace all the missing POSIX tools, LFNs, long cmdlines,
> etc. for you, sadly.
dos_bin probably would run, though I've not checked--it certainly did run once, well enough to build Perl.
But this suggests that pdksh might be ported to DJGPP easily.

> > Also, ack just might be able to compile mksh on DOS--it can on Minix 3.
>
> ACK doesn't have a DOS port, does it?
ISTR seeing an ACK compiler under the freedos directory on ibiblio...but it might not be a port.

A third option, that might not be wise, is building an ELKS shell, using bcc in DOS mode (bcc bootstraps all ELKS binaries, and it has a flag to output DOS .COM binaries).
However, this would be 16-bit, fairly tight, SFN, and all that.

Rugxulo(R)

Homepage

Usono,
11.01.2012, 05:47

@ Ibidem

mksh (Rugxulo, please come in!)

> > > FWIW, a port of pdksh is also available:
> > >
> http://www.ilyaz.org/software/os2/
> > > dos_bin.zip has the one known to run on DOS, but maybe the EMX
> versions
> > > also do...

A quick look only shows sh_dos.zip, which I assume is what you meant. It is pdksh compiled by EMX, assumes OS/2 or RSX via execve() function call.

> > But it may only work with EMX, and that barely works on DOS. In other
> > words, it won't replace all the missing POSIX tools, LFNs, long
> cmdlines,
> > etc. for you, sadly.
> dos_bin probably would run, though I've not checked--it certainly did run
> once, well enough to build Perl.
> But this suggests that pdksh might be ported to DJGPP easily.

DJGPP has built-in support for LFNs, long cmdlines, and these are things that only work with DJGPP-compiled apps.

Sure, pdksh could (mostly) be ported to DJGPP, but the main problem is a lack of fork(). DJGPP already has "good enough" POSIX support.

> > > Also, ack just might be able to compile mksh on DOS--it can on Minix
> 3.
> > ACK doesn't have a DOS port, does it?
> ISTR seeing an ACK compiler under the freedos directory on ibiblio...but it
> might not be a port.

I don't know of any ACK on FreeDOS' iBiblio mirror, though I know at one time Pat made a Cygwin-hosted cross compiler for it (presumably targeting Minix's a.out, I don't think he wrote a new backend).

> A third option, that might not be wise, is building an ELKS shell, using
> bcc in DOS mode (bcc bootstraps all ELKS binaries, and it has a flag to
> output DOS .COM binaries).
> However, this would be 16-bit, fairly tight, SFN, and all that.

I think ELKS supports multitasking and fork() natively, something that most DOSes (e.g. FreeDOS) lack, so it won't be that easy. Same problem. Yes, Dev86 has a DOS target (w/ library), but I'm pretty sure it doesn't have fork().

Back to the board
Thread view  Mix view  Order
15112 Postings in 1359 Threads, 247 registered users, 15 users online (0 registered, 15 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum