<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">

<html>

<head>
<title>NT POSIX</title>
<meta name="GENERATOR" content="Microsoft FrontPage 1.1">
<meta name="FORMATTER" content="Microsoft FrontPage 2.0">
</head>

<body stylesrc="logo.htm" bgcolor="#FFFFFF">

<h3 align="center">NT's POSIX</h3>

<p><u>Where can I get Microsoft's POSIX subsystem for NT?</u> </p>

<p>NT has a built-in protected subsystem for POSIX. It starts
automatically when a POSIX application loads and stays active
until shutdown. The process name is psxss. </p>

<p>Microsoft provides a series of POSIX utilities, including
source code, in the <a href="http://www.microsoft.com"
target="_top">Resource Kit</a>. Some of the included utilities
are: <i>ar, cat, chmod, vi, ls, mv, rm, </i>and <i>sh</i>. </p>

<p>The Resource Kit can be purchased from Microsoft, or Software
Spectrum (US 800-824-3323, Canada 800-624-6224). </p>

<p>You can also <a
href="http://www.microsoft.com/BackOffice/ntutil.htm"
target="_top">download the utilities</a> for free. </p>

<p>The Reskit is not enough to develop POSIX applications - you
really need the SDK from, again, MSDN Level 2. </p>

<p><u>What are the restrictions of NT's POSIX?</u> </p>

<p>The POSIX subsystem that is supplied by Microsoft with NT has
several important limitations. </p>

<p>To quote the Resource Kit: </p>

<blockquote>
    <p>With this release of Windows NT, POSIX applications have
    no direct access to any of the facilities and features of the
    Win32 subsystem, such as memory mapped files, networking,
    graphics, or dynamic data exchange. </p>
</blockquote>

<p>That one sentence says a lot! No networking means no Winsock
or any other communication protocol. No graphics means that you
restricted to only console-based (Command Window) applications.
No memory mapped files restricts one of the methods of
communicating between processes under NT. Simply stated,
applications using the POSIX subsystem of NT can't do a whole
lot. To do anything interesting, you need to access Microsoft's
Win32 API, or at least wrap a series of Unix-like calls around
the Win32 API.</p>

<p><u>Why is the POSIX subsystem so brain-damaged?</u> </p>

<p>The general consensus is that Microsoft put in the POSIX
subsystem in order to bid NT on U.S. government contracts where
POSIX can be a requirement. The NT implementation is a strict
implementation of the POSIX.1 standard and nothing more. So, the
subsystem isn't so much as brain-damaged, but severely
handicapped by not adding anything beyond the specification. </p>

<p>The unfortunate result for those wishing to port UNIX
applications, is that unless the application needs no more system
resources than <i>cat</i>, the POSIX subsystem is useless. In
fact, attempting to port to the POSIX subsystem will probably be
a complete waste of time as any one of several brick walls will
be hit very quickly. The alternative is to start with the Win32
API and one of several porting aids listed in the next section. </p>

<p><u>How do I get </u><i><u>vi</u></i><u> to run?</u> </p>

<p>Ah yes, one of the great secrets of the NT POSIX subsystem.
See also Knowledge Base article <a
href="http://www.microsoft.com/Support/KBSL/bussys/winnt/Q108581.htm"
target="_top">Q108581</a>. </p>

<p>First, you need to create a termcap file: </p>

<pre>
li|ansi|psx_ansi|:\
     :co#80:li#25:\ 
     :am:pt:ms:bw:\ 
     :cl=\E[2J:cm=\E[%i%d;%dH:ce=\E[K:cd=\E[J:\
     :sf=\E[S:sr=\E[T:\ 
     :ho=\E[H:sc=\E[s:rc=\E[u:up=\E[A:d=^J:nd=\E[C:le=^H:\ 
     :ku=\E[A:kd=\E[V:kr=\E[C:kl=\E[D:kb=^H:\ 
     :so=\E[7m:se=\E[m:mr=\E[7m:me=\E[0m:\
</pre>

<p>Second, you need to a bunch of environment variables: </p>

<pre>
SET _POSIX_TERM=on
SET TERM=ansi
SET TERMCAP=location of termcap file in POSIX file format
which is case-sensitive.
e.g. SET TERMCAP=//D/RESKIT35/posix/termcap
SET TMP=//C/TEMP
</pre>

<p>Important note: setting the TMP environment variable in POSIX
style renders it incompatible with a lot of other applications,
including Visual C++. So you should have a separate command
window just for vi. All the other variables may be permanently
set in the Control Panel\System applet. </p>

<p>That should be it. </p>

<p><u>Where can I found more about NT's POSIX subsystem?</u> </p>

<p>In the NT 3.5 Resource Kit, Resource Guide, Chapter 17 - POSIX
Compatibility. </p>

<p><u>Where can I find a version of POSIX for NT that actually
works?</u></p>

<p>From <a href="http://www.softway.com" target="_top">Software
Systems Inc</a>. They make a product called <a
href="http://www.softway.com/OpenNT" target="_top">OpenNT</a>,
which a drop-in replacement for the brain-damaged built-in POSIX
subsystem.</p>
</body>
</html>