1 If you read this file _as_is_, just ignore the funny characters you
2 see. It is written in the POD format (see perlpod manpage) which is
3 specially designed to be readable as is.
7 perlos2 - Perl under OS/2, DOS, Win0.3*, Win0.95 and WinNT.
11 One can read this document in the following formats:
18 to list some (not all may be available simultaneously), or it may
19 be read I<as is>: either as F<README.os2>, or F<pod/perlos2.pod>.
21 To read the F<.INF> version of documentation (B<very> recommended)
22 outside of OS/2, one needs an IBM's reader (may be available on IBM
23 ftp sites (?) (URL anyone?)) or shipped with PC DOS 7.0.
29 perlos2 - Perl under OS/2
37 - Starting Perl programs under OS/2
38 - Starting OS/2 programs under Perl
39 Frequently asked questions
40 - I cannot run external programs
41 - I cannot embed perl into my program, or use perl.dll from my program.
43 - Automatic binary installation
44 - Manual binary installation
46 Accessing documentation
57 - Application of the patches
61 - Installing the built perl
64 - Some / became \ in pdksh.
65 - 'errno' - unresolved external
67 - Some problem (forget which ;-)
68 - Library ... not found
70 Specific (mis)features of OS/2 port
71 - setpriority, getpriority
82 - Why dynamic linking?
94 - Calls to external programs
102 The target is to make OS/2 the best supported platform for
103 using/building/developing Perl and I<Perl applications>, as well as
104 make Perl the best language to use under OS/2.
106 The current state is quite close to this target. Known limitations:
112 Some *nix programs use fork() a lot, but currently fork() is not
113 supported after I<use>ing dynamically loaded extensions.
117 You need a separate perl executable F<perl__.exe> (see L<perl__.exe>)
118 to use PM code in your application (like the forthcoming Perl/Tk).
122 There is no simple way to access B<WPS> objects. The only way I know
123 is via C<OS2::REXX> extension (see L<OS2::REXX>), and we do not have access to
124 convenience methods of B<Object REXX>. (Is it possible at all? I know
125 of no B<Object-REXX> API.)
129 Please keep this list up-to-date by informing me about other items.
133 Since OS/2 port of perl uses a remarkable B<EMX> environment, it can
134 run (and build extensions, and - possibly - be build itself) under any
135 environment which can run EMX. The current list is DOS,
136 DOS-inside-OS/2, Win0.3*, Win0.95 and WinNT. Out of many perl flavors,
137 only one works, see L<"perl_.exe">.
139 Note that not all features of Perl are available under these
140 environments. This depends on the features the I<extender> - most
141 probably C<RSX> - decided to implement.
143 Cf. L<Prerequisites>.
151 B<EMX> runtime is required (may be substituted by B<RSX>). Note that
152 it is possible to make F<perl_.exe> to run under DOS without any
153 external support by binding F<emx.exe>/F<rsx.exe> to it, see L<emxbind>. Note
154 that under DOS for best results one should use B<RSX> runtime, which
155 has much more functions working (like C<fork>, C<popen> and so on). In
156 fact B<RSX> is required if there is no C<VCPI> present. Note the
157 B<RSX> requires C<DPMI>.
159 Only the latest runtime is supported, currently C<0.9c>.
161 One can get different parts of B<EMX> from, say
163 ftp://ftp.cdrom.com/pub/os2/emx0.9c/
164 ftp://hobbes.nmsu.edu/os2/unix/gnu/
166 The runtime component should have the name F<emxrt.zip>.
168 B<NOTE>. It is enough to have F<emx.exe>/F<rsx.exe> on your path. One
169 does not need to specify them explicitly (though this
177 To run Perl on C<DPMI> platforms one needs B<RSX> runtime. This is
178 needed under DOS-inside-OS/2, Win0.3*, Win0.95 and WinNT (see
179 L<"Other OSes">). B<RSX> would not work with C<VCPI>
180 only, as B<EMX> would, it requires C<DMPI>.
182 Having B<RSX> and the latest F<sh.exe> one gets a fully functional
183 B<*nix>-ish environment under DOS, say, C<fork>, C<``> and
184 pipe-C<open> work. In fact, MakeMaker works (for static build), so one
185 can have Perl development environment under DOS.
187 One can get B<RSX> from, say
189 ftp://ftp.cdrom.com/pub/os2/emx0.9c/contrib
190 ftp://ftp.uni-bielefeld.de/pub/systems/msdos/misc
192 Contact the author on C<rainer@mathematik.uni-bielefeld.de>.
194 The latest F<sh.exe> with DOS hooks is available at
196 ftp://ftp.math.ohio-state.edu/pub/users/ilya/os2/sh_dos.exe
200 Perl does not care about file systems, but to install the whole perl
201 library intact one needs a file system which supports long file names.
203 Note that if you do not plan to build the perl itself, it may be
204 possible to fool B<EMX> to truncate file names. This is not supported,
205 read B<EMX> docs to see how to do it.
209 =head2 Starting Perl programs under OS/2
211 Start your Perl program F<foo.pl> with arguments C<arg1 arg2 arg3> the
212 same way as on any other platform, by
214 perl foo.pl arg1 arg2 arg3
216 If you want to specify perl options C<-my_opts> to the perl itself (as
217 opposed to to your program), use
219 perl -my_opts foo.pl arg1 arg2 arg3
221 Alternately, if you use OS/2-ish shell, like C<CMD> or C<4os2>, put
222 the following at the start of your perl script:
225 #!/usr/bin/perl -my_opts
227 rename your program to F<foo.cmd>, and start it by typing
231 (Note that having *nixish full path to perl F</usr/bin/perl> is not
232 necessary, F<perl> would be enough, but having full path would make it
233 easier to use your script under *nix.)
235 Note that because of stupid OS/2 limitations the full path of the perl
236 script is not available when you use C<extproc>, thus you are forced to
237 use C<-S> perl switch, and your script should be on path. As a plus
238 side, if you know a full path to your script, you may still start it
241 perl -x ../../blah/foo.cmd arg1 arg2 arg3
243 (note that the argument C<-my_opts> is taken care of by the C<#!> line
246 To understand what the above I<magic> does, read perl docs about C<-S>
247 and C<-x> switches - see L<perlrun>, and cmdref about C<extproc>:
254 or whatever method you prefer.
256 There are also endless possibilities to use I<executable extensions> of
257 B<4OS2>, I<associations> of B<WPS> and so on... However, if you use
258 *nixish shell (like F<sh.exe> supplied in the binary distribution),
259 you need to follow the syntax specified in L<perlrun/"Switches">.
261 =head2 Starting OS/2 programs under Perl
263 This is what system() (see L<perlfunc/system>), C<``> (see
264 L<perlop/"I/O Operators">), and I<open pipe> (see L<perlfunc/open>)
265 are for. (Avoid exec() (see L<perlfunc/exec>) unless you know what you
268 Note however that to use some of these operators you need to have a
269 C<sh>-syntax shell installed (see L<"Pdksh">,
270 L<"Frequently asked questions">), and perl should be able to find it
271 (see L<"PERL_SH_DIR">).
273 The only cases when the shell is not used is the multi-argument
274 system() (see L<perlfunc/system>)/exec() (see L<perlfunc/exec>), and
275 one-argument version thereof without redirection and shell
278 =head1 Frequently asked questions
280 =head2 I cannot run external programs
286 Did you run your programs with C<-w> switch? See
287 L<Starting OS/2 programs under Perl>.
291 Do you try to run I<internal> shell commands, like C<`copy a b`>
292 (internal for F<cmd.exe>), or C<`glob a*b`> (internal for ksh)? You
293 need to specify your shell explicitly, like C<`cmd /c copy a b`>,
294 since Perl cannot deduce which commands are internal to your shell.
298 =head2 I cannot embed perl into my program, or use F<perl.dll> from my
303 =item Is your program B<EMX>-compiled with C<-Zmt -Zcrtdll>?
305 If not, you need to build a stand-alone DLL for perl. Contact me, I
306 did it once. Sockets would not work, as a lot of other stuff.
308 =item Did you use C<ExtUtils::Embed>?
310 I had reports it does not work. Somebody would need to fix it.
314 =head2 C<``> and pipe-C<open> do not work under DOS.
316 This may a variant of just L<"I cannot run external programs">, or a
317 deeper problem. Basically: you I<need> B<RSX> (see L<"Prerequisites">)
318 for these commands to work, and you may need a port of F<sh.exe> which
319 understands command arguments. One of such ports is listed in
320 L<"Prerequisites"> under B<RSX>.
322 C<DPMI> is required for B<RSX>.
326 =head2 Automatic binary installation
328 The most convenient way of installing perl is via perl installer
329 F<install.exe>. Just follow the instructions, and 99% of the
330 installation blues would go away.
332 Note however, that you need to have F<unzip.exe> on your path, and
333 B<EMX> environment I<running>. The latter means that if you just
334 installed B<EMX>, and made all the needed changes to F<Config.sys>,
335 you may need to reboot in between. Check B<EMX> runtime by running
339 A folder is created on your desktop which contains some useful
342 B<Things not taken care of by automatic binary installation:>
346 =item C<PERL_BADLANG>
348 may be needed if you change your codepage I<after> perl installation,
349 and the new value is not supported by B<EMX>. See L<"PERL_BADLANG">.
351 =item C<PERL_BADFREE>
353 see L<"PERL_BADFREE">.
357 This file resides somewhere deep in the location you installed your
358 perl library, find it out by
360 perl -MConfig -le "print $INC{'Config.pm'}"
362 While most important values in this file I<are> updated by the binary
363 installer, some of them may need to be hand-edited. I know no such
364 data, please keep me informed if you find one.
368 =head2 Manual binary installation
370 As of version 5.00305, OS/2 perl binary distribution comes split
371 into 11 components. Unfortunately, to enable configurable binary
372 installation, the file paths in the C<zip> files are not absolute, but
373 relative to some directory.
375 Note that the extraction with the stored paths is still necessary
376 (default with C<unzip>, specify C<-d> to C<pkunzip>). However, you
377 need to know where to extract the files. You need also to manually
378 change entries in F<Config.sys> to reflect where did you put the
379 files. Note that if you have some primitive unzipper (like
380 C<pkunzip>), you may get a lot of warnings/errors during
381 unzipping. Upgrade to C<(w)unzip>.
383 Below is the sample of what to do to reproduce the configuration on my
388 =item Perl VIO and PM executables (dynamically linked)
390 unzip perl_exc.zip *.exe *.ico -d f:/emx.add/bin
391 unzip perl_exc.zip *.dll -d f:/emx.add/dll
393 (have the directories with C<*.exe> on C<PATH>, and C<*.dll> on
396 =item Perl_ VIO executable (statically linked)
398 unzip perl_aou.zip -d f:/emx.add/bin
400 (have the directory on C<PATH>);
402 =item Executables for Perl utilities
404 unzip perl_utl.zip -d f:/emx.add/bin
406 (have the directory on C<PATH>);
408 =item Main Perl library
410 unzip perl_mlb.zip -d f:/perllib/lib
412 If this directory is preserved, you do not need to change
413 anything. However, for perl to find it if it is changed, you need to
414 C<set PERLLIB_PREFIX> in F<Config.sys>, see L<"PERLLIB_PREFIX">.
416 =item Additional Perl modules
418 unzip perl_ste.zip -d f:/perllib/lib/site_perl
420 If you do not change this directory, do nothing. Otherwise put this
421 directory and subdirectory F<./os2> in C<PERLLIB> or C<PERL5LIB>
422 variable. Do not use C<PERL5LIB> unless you have it set already. See
423 L<perl/"ENVIRONMENT">.
425 =item Tools to compile Perl modules
427 unzip perl_blb.zip -d f:/perllib/lib
429 If this directory is preserved, you do not need to change
430 anything. However, for perl to find it if it is changed, you need to
431 C<set PERLLIB_PREFIX> in F<Config.sys>, see L<"PERLLIB_PREFIX">.
433 =item Manpages for Perl and utilities
435 unzip perl_man.zip -d f:/perllib/man
437 This directory should better be on C<MANPATH>. You need to have a
438 working C<man> to access these files.
440 =item Manpages for Perl modules
442 unzip perl_mam.zip -d f:/perllib/man
444 This directory should better be on C<MANPATH>. You need to have a
445 working C<man> to access these files.
447 =item Source for Perl documentation
449 unzip perl_pod.zip -d f:/perllib/lib
451 This is used by by C<perldoc> program (see L<perldoc>), and may be used to
452 generate B<HTML> documentation usable by WWW browsers, and
453 documentation in zillions of other formats: C<info>, C<LaTeX>,
454 C<Acrobat>, C<FrameMaker> and so on.
456 =item Perl manual in .INF format
458 unzip perl_inf.zip -d d:/os2/book
460 This directory should better be on C<BOOKSHELF>.
464 unzip perl_sh.zip -d f:/bin
466 This is used by perl to run external commands which explicitly
467 require shell, like the commands using I<redirection> and I<shell
468 metacharacters>. It is also used instead of explicit F</bin/sh>.
470 Set C<PERL_SH_DIR> (see L<"PERL_SH_DIR">) if you move F<sh.exe> from
473 B<Note.> It may be possible to use some other C<sh>-compatible shell
478 After you installed the components you needed and updated the
479 F<Config.sys> correspondingly, you need to hand-edit
480 F<Config.pm>. This file resides somewhere deep in the location you
481 installed your perl library, find it out by
483 perl -MConfig -le "print $INC{'Config.pm'}"
485 You need to correct all the entries which look like file paths (they
486 currently start with C<f:/>).
490 The automatic and manual perl installation leave precompiled paths
491 inside perl executables. While these paths are overwriteable (see
492 L<"PERLLIB_PREFIX">, L<"PERL_SH_DIR">), one may get better results by
493 binary editing of paths inside the executables/DLLs.
495 =head1 Accessing documentation
497 Depending on how you built/installed perl you may have (otherwise
498 identical) Perl documentation in the following formats:
500 =head2 OS/2 F<.INF> file
502 Most probably the most convenient form. View it as
507 view perl ExtUtils::MakeMaker
509 (currently the last two may hit a wrong location, but this may improve
512 If you want to build the docs yourself, and have I<OS/2 toolkit>, run
516 in F</perllib/lib/pod> directory, then
520 (Expect a lot of errors during the both steps.) Now move it on your
525 If you have perl documentation in the source form, perl utilities
526 installed, and B<GNU> C<groff> installed, you may use
530 perldoc ExtUtils::MakeMaker
532 to access the perl documentation in the text form (note that you may get
533 better results using perl manpages).
535 Alternately, try running pod2text on F<.pod> files.
539 If you have C<man> installed on your system, and you installed perl
540 manpages, use something like this:
544 man ExtUtils.MakeMaker
546 to access documentation for different components of Perl. Start with
550 Note that dot (F<.>) is used as a package separator for documentation
551 for packages, and as usual, sometimes you need to give the section - C<3>
552 above - to avoid shadowing by the I<less(1) manpage>.
554 Make sure that the directory B<above> the directory with manpages is
555 on our C<MANPATH>, like this
557 set MANPATH=c:/man;f:/perllib/man
561 If you have some WWW browser available, installed the Perl
562 documentation in the source form, and Perl utilities, you can build
563 B<HTML> docs. Cd to directory with F<.pod> files, and do like this
565 cd f:/perllib/lib/pod
568 After this you can direct your browser the file F<perl.html> in this
569 directory, and go ahead with reading docs, like this:
571 explore file:///f:/perllib/lib/pod/perl.html
573 Alternatively you may be able to get these docs prebuilt from C<CPAN>.
575 =head2 B<GNU> C<info> files
577 Users of C<Emacs> would appreciate it very much, especially with
578 C<CPerl> mode loaded. You need to get latest C<pod2info> from C<CPAN>,
579 or, alternately, prebuilt info pages.
583 for C<Acrobat> are available on CPAN (for slightly old version of
588 can be constructed using C<pod2latex>.
592 Here we discuss how to build Perl under OS/2. There is an alternative
593 (but maybe older) view on L<http://www.shadow.net/~troc/os2perl.html>.
597 You need to have the latest B<EMX> development environment, the full
598 B<GNU> tool suite (C<gawk> renamed to C<awk>, and B<GNU> F<find.exe>
599 earlier on path than the OS/2 F<find.exe>, same with F<sort.exe>, to
605 ). You need the latest version of F<pdksh> installed as F<sh.exe>.
607 Possible locations to get this from are
609 ftp://hobbes.nmsu.edu/os2/unix/gnu/
610 ftp://ftp.cdrom.com/pub/os2/unix/
611 ftp://ftp.cdrom.com/pub/os2/dev32/
612 ftp://ftp.cdrom.com/pub/os2/emx0.9c/
615 Make sure that no copies or perl are currently running. Later steps
616 of the build may fail since an older version of perl.dll loaded into
619 Also make sure that you have F</tmp> directory on the current drive,
620 and F<.> directory in your C<LIBPATH>. One may try to correct the
625 if you use something like F<CMD.EXE> or latest versions of F<4os2.exe>.
627 Make sure your C<gcc> is good for C<-Zomf> linking: run C<omflibs>
628 script in F</emx/lib> directory.
630 Check that you have C<link386> installed. It comes standard with OS/2,
631 but may be not installed due to customization. If typing
635 shows you do not have it, do I<Selective install>, and choose C<Link
636 object modules> in I<Optional system utilities/More>. If you get into
637 C<link386>, press C<Ctrl-C>.
639 =head2 Getting perl source
641 You need to fetch the latest perl source (including developers
642 releases). With some probability it is located in
644 http://www.perl.com/CPAN/src/5.0
645 http://www.perl.com/CPAN/src/5.0/unsupported
647 If not, you may need to dig in the indices to find it in the directory
648 of the current maintainer.
650 Quick cycle of developers release may break the OS/2 build time to
653 http://www.perl.com/CPAN/ports/os2/ilyaz/
655 may indicate the latest release which was publicly released by the
656 maintainer. Note that the release may include some additional patches
657 to apply to the current source of perl.
661 tar vzxf perl5.00409.tar.gz
663 You may see a message about errors while extracting F<Configure>. This is
664 because there is a conflict with a similarly-named file F<configure>.
666 Rename F<configure> to F<configure.gnu>. Extract F<Configure> like this
668 tar --case-sensitive -vzxf perl5.00409.tar.gz perl5.00409/Configure
670 Change to the directory of extraction.
672 =head2 Application of the patches
674 You need to apply the patches in F<./os2/diff.*> and
675 F<./os2/POSIX.mkfifo> like this:
677 gnupatch -p0 < os2\POSIX.mkfifo
678 gnupatch -p0 < os2\os2\diff.configure
680 You may also need to apply the patches supplied with the binary
681 distribution of perl.
683 Note also that the F<db.lib> and F<db.a> from the B<EMX> distribution
684 are not suitable for multi-threaded compile (note that currently perl
685 is not multithreaded, but is compiled as multithreaded for
686 compatibility with B<XFree86>-OS/2). Get a corrected one from
688 ftp://ftp.math.ohio-state.edu/pub/users/ilya/os2/db_mt.zip
692 You may look into the file F<./hints/os2.sh> and correct anything
693 wrong you find there. I do not expect it is needed anywhere.
697 sh Configure -des -D prefix=f:/perllib
699 Prefix means where to install the resulting perl library. Giving
700 correct prefix you may avoid the need to specify C<PERLLIB_PREFIX>,
701 see L<"PERLLIB_PREFIX">.
703 I<Ignore the message about missing C<ln>, and about C<-c> option to
704 C<tr>>. In fact if you can trace where the latter spurious warning
705 comes from, please inform me.
711 At some moment the built may die, reporting a I<version mismatch> or
712 I<unable to run F<perl>>. This means that most of the build has been
713 finished, and it is the time to move the constructed F<perl.dll> to
714 some I<absolute> location in C<LIBPATH>. After this done the build
715 should finish without a lot of fuss. I<One can avoid it if one has the
716 correct prebuilt version of F<perl.dll> on C<LIBPATH>.>
718 Warnings which are safe to ignore: I<mkfifo() redefined> inside
727 Some tests (4..6) should fail. Some perl invocations should end in a
728 segfault (system error C<SYS3175>). To get finer error reports,
731 perl -I ../lib harness
733 The report you get may look like
735 Failed Test Status Wstat Total Fail Failed List of failed
736 ---------------------------------------------------------------
737 io/fs.t 26 11 42.31% 2-5, 7-11, 18, 25
738 lib/io_pipe.t 3 768 6 ?? % ??
739 lib/io_sock.t 3 768 5 ?? % ??
740 op/stat.t 56 5 8.93% 3-4, 20, 35, 39
741 Failed 4/140 test scripts, 97.14% okay. 27/2937 subtests failed, 99.08% okay.
743 Note that using `make test' target two more tests may fail: C<op/exec:1>
744 because of (mis)feature of C<pdksh>, and C<lib/posix:15>, which checks
745 that the buffers are not flushed on C<_exit> (this is a bug in the test
746 which assumes that tty output is buffered).
748 I submitted a patch to B<EMX> which makes it possible to fork() with EMX
749 dynamic libraries loaded, which makes F<lib/io*> tests pass. This means
750 that soon the number of failing tests may decrease yet more.
752 However, the test F<lib/io_udp.t> is disabled, since it never ends, I
755 The reasons for failed tests are:
761 Checks I<file system> operations. Tests:
767 Check C<link()> and C<inode count> - nonesuch under OS/2.
771 Checks C<atime> and C<mtime> of C<stat()> - I could not understand this test.
775 Checks C<truncate()> on a filehandle just opened for write - I do not
776 know why this should or should not work.
780 =item F<lib/io_pipe.t>
782 Checks C<IO::Pipe> module. Some feature of B<EMX> - test fork()s with
783 dynamic extension loaded - unsupported now.
785 =item F<lib/io_sock.t>
787 Checks C<IO::Socket> module. Some feature of B<EMX> - test fork()s
788 with dynamic extension loaded - unsupported now.
792 Checks C<stat()>. Tests:
798 Checks C<inode count> - nonesuch under OS/2.
802 Checks C<mtime> and C<ctime> of C<stat()> - I could not understand this test.
806 Checks C<-x> - determined by the file extension only under OS/2.
814 Checks C<-t> of F</dev/null>. Should not fail!
820 In addition to errors, you should get a lot of warnings.
824 =item A lot of `bad free'
826 in databases related to Berkeley DB. This is a confirmed bug of
827 DB. You may disable this warnings, see L<"PERL_BADFREE">.
829 =item Process terminated by SIGTERM/SIGINT
831 This is a standard message issued by OS/2 applications. *nix
832 applications die in silence. It is considered a feature. One can
833 easily disable this by appropriate sighandlers.
835 However the test engine bleeds these message to screen in unexpected
836 moments. Two messages of this kind I<should> be present during
839 =item F<*/sh.exe>: ln: not found
841 =item C<ls>: /dev: No such file or directory
843 The last two should be self-explanatory. The test suite discovers that
844 the system it runs on is not I<that much> *nixish.
848 A lot of `bad free'... in databases, bug in DB confirmed on other
849 platforms. You may disable it by setting PERL_BADFREE environment variable
852 =head2 Installing the built perl
858 It would put the generated files into needed locations. Manually put
859 F<perl.exe>, F<perl__.exe> and F<perl___.exe> to a location on your
860 C<PATH>, F<perl.dll> to a location on your C<LIBPATH>.
864 make cmdscripts INSTALLCMDDIR=d:/ir/on/path
866 to convert perl utilities to F<.cmd> files and put them on
867 C<PATH>. You need to put F<.EXE>-utilities on path manually. They are
868 installed in C<$prefix/bin>, here C<$prefix> is what you gave to
869 F<Configure>, see L<Making>.
871 =head2 C<a.out>-style build
873 Proceed as above, but make F<perl_.exe> (see L<"perl_.exe">) by
882 Manually put F<perl_.exe> to a location on your C<PATH>.
884 Since C<perl_> has the extensions prebuilt, it does not suffer from
885 the I<dynamic extensions + fork()> syndrome, thus the failing tests
888 Failed Test Status Wstat Total Fail Failed List of failed
889 ---------------------------------------------------------------
890 io/fs.t 26 11 42.31% 2-5, 7-11, 18, 25
891 op/stat.t 56 5 8.93% 3-4, 20, 35, 39
892 Failed 2/118 test scripts, 98.31% okay. 16/2445 subtests failed, 99.35% okay.
894 B<Note.> The build process for C<perl_> I<does not know> about all the
895 dependencies, so you should make sure that anything is up-to-date,
904 =head2 Some C</> became C<\> in pdksh.
906 You have a very old pdksh. See L<Prerequisites>.
908 =head2 C<'errno'> - unresolved external
910 You do not have MT-safe F<db.lib>. See L<Prerequisites>.
912 =head2 Problems with C<tr>
914 reported with very old version of C<tr>.
916 =head2 Some problem (forget which ;-)
918 You have an older version of F<perl.dll> on your C<LIBPATH>, which
919 broke the build of extensions.
921 =head2 Library ... not found
923 You did not run C<omflibs>. See L<Prerequisites>.
925 =head2 Segfault in make
927 You use an old version of C<GNU> make. See L<Prerequisites>.
929 =head1 Specific (mis)features of OS/2 port
931 =head2 C<setpriority>, C<getpriority>
933 Note that these functions are compatible with *nix, not with the older
934 ports of '94 - 95. The priorities are absolute, go from 32 to -95,
935 lower is quicker. 0 is the default priority.
939 Multi-argument form of C<system()> allows an additional numeric
940 argument. The meaning of this argument is described in
943 =head2 Additional modules:
945 L<OS2::Process>, L<OS2::REXX>, L<OS2::PrfDB>, L<OS2::ExtAttr>. This
946 modules provide access to additional numeric argument for C<system>,
947 to DLLs having functions with REXX signature and to REXX runtime, to
948 OS/2 databases in the F<.INI> format, and to Extended Attributes.
950 Two additional extensions by Andreas Kaiser, C<OS2::UPM>, and
951 C<OS2::FTP>, are included into my ftp directory, mirrored on CPAN.
953 =head2 Prebuilt methods:
957 =item C<File::Copy::syscopy>
959 used by C<File::Copy::copy>, see L<File::Copy/copy>.
961 =item C<DynaLoader::mod2fname>
963 used by C<DynaLoader> for DLL name mangling.
965 =item C<Cwd::current_drive()>
969 =item C<Cwd::sys_chdir(name)>
971 leaves drive as it is.
973 =item C<Cwd::change_drive(name)>
976 =item C<Cwd::sys_is_absolute(name)>
978 means has drive letter and is_rooted.
980 =item C<Cwd::sys_is_rooted(name)>
982 means has leading C<[/\\]> (maybe after a drive-letter:).
984 =item C<Cwd::sys_is_relative(name)>
986 means changes with current dir.
988 =item C<Cwd::sys_cwd(name)>
990 Interface to cwd from B<EMX>. Used by C<Cwd::cwd>.
992 =item C<Cwd::sys_abspath(name, dir)>
994 Really really odious function to implement. Returns absolute name of
995 file which would have C<name> if CWD were C<dir>. C<Dir> defaults to the
998 =item C<Cwd::extLibpath([type])
1000 Get current value of extended library search path. If C<type> is
1001 present and I<true>, works with END_LIBPATH, otherwise with
1004 =item C<Cwd::extLibpath_set( path [, type ] )>
1006 Set current value of extended library search path. If C<type> is
1007 present and I<true>, works with END_LIBPATH, otherwise with
1012 (Note that some of these may be moved to different libraries -
1022 Since <flock> is present in B<EMX>, but is not functional, the same is
1023 true for perl. Here is the list of things which may be "broken" on
1024 EMX (from EMX docs):
1026 - The functions recvmsg(), sendmsg(), and socketpair() are not
1028 - sock_init() is not required and not implemented.
1029 - flock() is not yet implemented (dummy function).
1031 Special treatment of PID=0, PID=1 and PID=-1 is not implemented.
1035 waitpid() is not implemented for negative values of PID.
1037 Note that C<kill -9> does not work with the current version of EMX.
1041 Since F<sh.exe> is used for globing (see L<perlfunc/glob>), the bugs
1042 of F<sh.exe> plague perl as well.
1044 In particular, uppercase letters do not work in C<[...]>-patterns with
1045 the current C<pdksh>.
1049 =head2 Modifications
1051 Perl modifies some standard C library calls in the following ways:
1057 C<my_popen> uses F<sh.exe> if shell is required, cf. L<"PERL_SH_DIR">.
1061 is created using C<TMP> or C<TEMP> environment variable, via
1066 If the current directory is not writable, file is created using modified
1067 C<tmpnam>, so there may be a race condition.
1071 a dummy implementation.
1075 C<os2_stat> special-cases F</dev/tty> and F</dev/con>.
1081 Because of idiosyncrasies of OS/2 one cannot have all the eggs in the
1082 same basket (though C<EMX> environment tries hard to overcome this
1083 limitations, so the situation may somehow improve). There are 4
1084 executables for Perl provided by the distribution:
1088 The main workhorse. This is a chimera executable: it is compiled as an
1089 C<a.out>-style executable, but is linked with C<omf>-style dynamic
1090 library F<perl.dll>, and with dynamic B<CRT> DLL. This executable is a
1093 It can load perl dynamic extensions, and it can fork(). Unfortunately,
1094 with the current version of B<EMX> it cannot fork() with dynamic
1095 extensions loaded (may be fixed by patches to B<EMX>).
1097 B<Note.> Keep in mind that fork() is needed to open a pipe to yourself.
1101 This is a statically linked C<a.out>-style executable. It can fork(),
1102 but cannot load dynamic Perl extensions. The supplied executable has a
1103 lot of extensions prebuilt, thus there are situations when it can
1104 perform tasks not possible using F<perl.exe>, like fork()ing when
1105 having some standard extension loaded. This executable is a C<VIO>
1108 B<Note.> A better behaviour could be obtained from C<perl.exe> if it
1109 were statically linked with standard I<Perl extensions>, but
1110 dynamically linked with the I<Perl DLL> and C<CRT> DLL. Then it would
1111 be able to fork() with standard extensions, I<and> would be able to
1112 dynamically load arbitrary extensions. Some changes to Makefiles and
1113 hint files should be necessary to achieve this.
1115 I<This is also the only executable with does not require OS/2.> The
1116 friends locked into C<M$> world would appreciate the fact that this
1117 executable runs under DOS, Win0.3*, Win0.95 and WinNT with an
1118 appropriate extender. See L<"Other OSes">.
1120 =head2 F<perl__.exe>
1122 This is the same executable as <perl___.exe>, but it is a C<PM>
1125 B<Note.> Usually C<STDIN>, C<STDERR>, and C<STDOUT> of a C<PM>
1126 application are redirected to C<nul>. However, it is possible to see
1127 them if you start C<perl__.exe> from a PM program which emulates a
1128 console window, like I<Shell mode> of C<Emacs> or C<EPM>. Thus it I<is
1129 possible> to use Perl debugger (see L<perldebug>) to debug your PM
1132 This flavor is required if you load extensions which use C<PM>, like
1133 the forthcoming C<Perl/Tk>.
1135 =head2 F<perl___.exe>
1137 This is an C<omf>-style executable which is dynamically linked to
1138 F<perl.dll> and C<CRT> DLL. I know no advantages of this executable
1139 over C<perl.exe>, but it cannot fork() at all. Well, one advantage is
1140 that the build process is not so convoluted as with C<perl.exe>.
1142 It is a C<VIO> application.
1144 =head2 Why strange names?
1146 Since Perl processes the C<#!>-line (cf.
1147 L<perlrun/DESCRIPTION>, L<perlrun/Switches>,
1148 L<perldiag/"Not a perl script">,
1149 L<perldiag/"No Perl script found in input">), it should know when a
1150 program I<is a Perl>. There is some naming convention which allows
1151 Perl to distinguish correct lines from wrong ones. The above names are
1152 almost the only names allowed by this convention which do not contain
1153 digits (which have absolutely different semantics).
1155 =head2 Why dynamic linking?
1157 Well, having several executables dynamically linked to the same huge
1158 library has its advantages, but this would not substantiate the
1159 additional work to make it compile. The reason is stupid-but-quick
1160 "hard" dynamic linking used by OS/2.
1162 The address tables of DLLs are patched only once, when they are
1163 loaded. The addresses of entry points into DLLs are guaranteed to be
1164 the same for all programs which use the same DLL, which reduces the
1165 amount of runtime patching - once DLL is loaded, its code is
1168 While this allows some performance advantages, this makes life
1169 terrible for developers, since the above scheme makes it impossible
1170 for a DLL to be resolved to a symbol in the .EXE file, since this
1171 would need a DLL to have different relocations tables for the
1172 executables which use it.
1174 However, a Perl extension is forced to use some symbols from the perl
1175 executable, say to know how to find the arguments provided on the perl
1176 internal evaluation stack. The solution is that the main code of
1177 interpreter should be contained in a DLL, and the F<.EXE> file just loads
1178 this DLL into memory and supplies command-arguments.
1180 This I<greatly> increases the load time for the application (as well as
1181 the number of problems during compilation). Since interpreter is in a DLL,
1182 the C<CRT> is basically forced to reside in a DLL as well (otherwise
1183 extensions would not be able to use C<CRT>).
1185 =head2 Why chimera build?
1187 Current C<EMX> environment does not allow DLLs compiled using Unixish
1188 C<a.out> format to export symbols for data. This forces C<omf>-style
1189 compile of F<perl.dll>.
1191 Current C<EMX> environment does not allow F<.EXE> files compiled in
1192 C<omf> format to fork(). fork() is needed for exactly three Perl
1197 =item explicit fork()
1205 opening pipes to itself.
1209 While these operations are not questions of life and death, a lot of
1210 useful scripts use them. This forces C<a.out>-style compile of
1216 Here we list environment variables with are either OS/2-specific, or
1217 are more important under OS/2 than under other OSes.
1219 =head2 C<PERLLIB_PREFIX>
1221 Specific for OS/2. Should have the form
1229 If the beginning of some prebuilt path matches F<path1>, it is
1230 substituted with F<path2>.
1232 Should be used if the perl library is moved from the default
1233 location in preference to C<PERL(5)LIB>, since this would not leave wrong
1236 =head2 C<PERL_BADLANG>
1238 If 1, perl ignores setlocale() failing. May be useful with some
1241 =head2 C<PERL_BADFREE>
1243 If 1, perl would not warn of in case of unwarranted free(). May be
1244 useful in conjunction with the module DB_File, since Berkeley DB
1245 memory handling code is buggy.
1247 =head2 C<PERL_SH_DIR>
1249 Specific for OS/2. Gives the directory part of the location for
1252 =head2 C<TMP> or C<TEMP>
1254 Specific for OS/2. Used as storage place for temporary files, most
1255 notably C<-e> scripts.
1259 Here we list major changes which could make you by surprise.
1263 C<setpriority> and C<getpriority> are not compatible with earlier
1264 ports by Andreas Kaiser. See C<"setpriority, getpriority">.
1266 =head2 DLL name mangling
1268 With the release 5.003_01 the dynamically loadable libraries
1269 should be rebuilt. In particular, DLLs are now created with the names
1270 which contain a checksum, thus allowing workaround for OS/2 scheme of
1275 As of release 5.003_01 perl is linked to multithreaded C<CRT>
1276 DLL. Perl itself is not multithread-safe, as is not perl
1277 malloc(). However, extensions may use multiple thread on their own
1280 Needed to compile C<Perl/Tk> for C<XFreeOS/2> out-of-the-box.
1282 =head2 Calls to external programs
1284 Due to a popular demand the perl external program calling has been
1285 changed wrt Andreas Kaiser's port. I<If> perl needs to call an
1286 external program I<via shell>, the F<f:/bin/sh.exe> will be called, or
1287 whatever is the override, see L<"PERL_SH_DIR">.
1289 Thus means that you need to get some copy of a F<sh.exe> as well (I
1290 use one from pdksh). The drive F: above is set up automatically during
1291 the build to a correct value on the builder machine, but is
1292 overridable at runtime,
1294 B<Reasons:> a consensus on C<perl5-porters> was that perl should use
1295 one non-overridable shell per platform. The obvious choices for OS/2
1296 are F<cmd.exe> and F<sh.exe>. Having perl build itself would be impossible
1297 with F<cmd.exe> as a shell, thus I picked up C<sh.exe>. Thus assures almost
1298 100% compatibility with the scripts coming from *nix.
1300 B<Disadvantages:> currently F<sh.exe> of C<pdksh> calls external programs
1301 via fork()/exec(), and there is I<no> functioning exec() on
1302 OS/2. exec() is emulated by EMX by asyncroneous call while the caller
1303 waits for child completion (to pretend that the C<pid> did not change). This
1304 means that 1 I<extra> copy of F<sh.exe> is made active via fork()/exec(),
1305 which may lead to some resources taken from the system (even if we do
1306 not count extra work needed for fork()ing).
1308 Note that this a lesser issue now when we do not spawn F<sh.exe>
1309 unless needed (metachars found).
1311 One can always start F<cmd.exe> explicitly via
1313 system 'cmd', '/c', 'mycmd', 'arg1', 'arg2', ...
1315 If you need to use F<cmd.exe>, and do not want to hand-edit thousands of your
1316 scripts, the long-term solution proposed on p5-p is to have a directive
1320 which will override system(), exec(), C<``>, and
1321 C<open(,'...|')>. With current perl you may override only system(),
1322 readpipe() - the explicit version of C<``>, and maybe exec(). The code
1323 will substitute the one-argument call to system() by
1324 C<CORE::system('cmd.exe', '/c', shift)>.
1326 If you have some working code for C<OS2::Cmd>, please send it to me,
1327 I will include it into distribution. I have no need for such a module, so
1334 I include 3 extensions by Andreas Kaiser, OS2::REXX, OS2::UPM, and OS2::FTP,
1335 into my ftp directory, mirrored on CPAN. I made
1336 some minor changes needed to compile them by standard tools. I cannot
1337 test UPM and FTP, so I will appreciate your feedback. Other extensions
1338 there are OS2::ExtAttr, OS2::PrfDB for tied access to EAs and .INI
1339 files - and maybe some other extensions at the time you read it.
1341 Note that OS2 perl defines 2 pseudo-extension functions
1342 OS2::Copy::copy and DynaLoader::mod2fname.
1344 The -R switch of older perl is deprecated. If you need to call a REXX code
1345 which needs access to variables, include the call into a REXX compartment
1347 REXX_call {...block...};
1349 Two new functions are supported by REXX code,
1351 REXX_eval_with 'string', REXX_function_name => \&perl_sub_reference;
1353 If you have some other extensions you want to share, send the code to
1354 me. At least two are available: tied access to EA's, and tied access
1355 to system databases.
1359 Ilya Zakharevich, ilya@math.ohio-state.edu