perlcygwin.html

来自「perl教程」· HTML 代码 · 共 675 行 · 第 1/3 页

HTML
675 行
字号
    sysopen(FOO, &quot;bar&quot;, O_WRONLY|O_CREAT|O_TEXT)</pre>
<p><code>lseek()</code>, <a href="../../lib/Pod/perlfunc.html#item_tell"><code>tell()</code></a> and <a href="../../lib/Pod/perlfunc.html#item_sysseek"><code>sysseek()</code></a> only work with files opened in binary
mode.</p>
<p>The text/binary issue is covered at length in the Cygwin documentation.</p>
</li>
<li><strong><a name="item_perlio">PerlIO</a></strong>

<p>PerlIO overrides the default Cygwin Text/Binary behaviour.  A file will 
always treated as binary, regardless which mode of the mount it lives on,
just like it is in UNIX.  So CR/LF translation needs to be requested in 
either the <a href="../../lib/Pod/perlfunc.html#item_open"><code>open()</code></a> call like this:</p>
<pre>
  <span class="keyword">open</span><span class="operator">(</span><span class="variable">FH</span><span class="operator">,</span> <span class="string">"&gt;:crlf"</span><span class="operator">,</span> <span class="string">"out.txt"</span><span class="operator">);</span>
</pre>
<p>which will do conversion from LF to CR/LF on the output, or in the 
environment settings (add this to your .bashrc):</p>
<pre>
  export PERLIO=crlf</pre>
<p>which will pull in the crlf PerlIO layer which does LF -&gt; CRLF conversion 
on every output generated by perl.</p>
</li>
<li><strong><a name="item__2eexe"><em>.exe</em></a></strong>

<p>The Cygwin <a href="../../lib/Pod/perlfunc.html#item_stat"><code>stat()</code></a>, <a href="../../lib/Pod/perlfunc.html#item_lstat"><code>lstat()</code></a> and <a href="../../lib/Pod/perlfunc.html#item_readlink"><code>readlink()</code></a> functions make the <em>.exe</em>
extension transparent by looking for <em>foo.exe</em> when you ask for <em>foo</em>
(unless a <em>foo</em> also exists).  Cygwin does not require a <em>.exe</em>
extension, but <em>gcc</em> adds it automatically when building a program.
However, when accessing an executable as a normal file (e.g., <em>cp</em>
in a makefile) the <em>.exe</em> is not transparent.  The <em>install</em> included
with Cygwin automatically appends a <em>.exe</em> when necessary.</p>
</li>
<li><strong><a name="item_cygwin_vs_2e_windows_process_ids">cygwin vs. windows process ids</a></strong>

<p>Cygwin processes have their own pid, which is different from the
underlying windows pid.  Most posix compliant Proc functions expect
the cygwin pid, but several Win32::Process functions expect the
winpid. E.g. <a href="../../lib/Pod/perlvar.html#item___"><code>$$</code></a> is the cygwin pid of <em>/usr/bin/perl</em>, which is not
the winpid.  Use <code>Cygwin::winpid_to_pid()</code> and <code>Cygwin::winpid_to_pid()</code> 
to translate between them.</p>
</li>
<li><strong><a name="item_chown"><code>chown()</code></a></strong>

<p>On WinNT <a href="#item_chown"><code>chown()</code></a> can change a file's user and group IDs.  On Win9x <a href="#item_chown"><code>chown()</code></a>
is a no-op, although this is appropriate since there is no security model.</p>
</li>
<li><strong><a name="item_miscellaneous">Miscellaneous</a></strong>

<p>File locking using the <code>F_GETLK</code> command to <a href="../../lib/Pod/perlfunc.html#item_fcntl"><code>fcntl()</code></a> is a stub that
returns <code>ENOSYS</code>.</p>
<p>Win9x can not <a href="../../lib/Pod/perlfunc.html#item_rename"><code>rename()</code></a> an open file (although WinNT can).</p>
<p>The Cygwin <a href="../../lib/Pod/perlfunc.html#item_chroot"><code>chroot()</code></a> implementation has holes (it can not restrict file
access by native Win32 programs).</p>
<p>Inplace editing <code>perl -i</code> of files doesn't work without doing a backup 
of the file being edited <code>perl -i.bak</code> because of windowish restrictions,
therefore Perl adds the suffix <code>.bak</code> automatically if you use <code>perl -i</code> 
without specifying a backup extension.</p>
<p>Using <a href="../../lib/Pod/perlfunc.html#item_fork"><code>fork()</code></a> after loading multiple dlls may fail with an internal cygwin
error like the following:</p>
<pre>
  C:\CYGWIN\BIN\PERL.EXE: *** couldn't allocate memory 0x10000(4128768) for 'C:\CYGWIN\LIB\PERL5\5.6.1\CYGWIN-MULTI\AUTO\SOCKET\SOCKET.DLL' alignment, Win32 error 8</pre>
<pre>
    200 [main] perl 377147 sync_with_child: child -395691(0xB8) died before initialization with status code 0x1
   1370 [main] perl 377147 sync_with_child: *** child state child loading dlls</pre>
<p>Use the rebase utility to resolve the conflicting dll addresses.  The
rebase package is included in the Cygwin netrelease.  Use setup.exe from
<em><a href="http://www.cygwin.com/setup.exe">http://www.cygwin.com/setup.exe</a></em> to install it and run rebaseall.</p>
</li>
</ul>
<p>
</p>
<h2><a name="prebuilt_methods_">Prebuilt methods:</a></h2>
<dl>
<dt><strong><a name="item_cwd_3a_3acwd"><code>Cwd::cwd</code></a></strong>

<dd>
<p>Returns current working directory.</p>
</dd>
</li>
<dt><strong><a name="item_cygwin_3a_3apid_to_winpid"><code>Cygwin::pid_to_winpid</code></a></strong>

<dd>
<p>Translates a cygwin pid to the corresponding Windows pid (which may or
may not be the same).</p>
</dd>
</li>
<dt><strong><a name="item_cygwin_3a_3awinpid_to_pid"><code>Cygwin::winpid_to_pid</code></a></strong>

<dd>
<p>Translates a Windows pid to the corresponding cygwin pid (if any).</p>
</dd>
</li>
</dl>
<p>
</p>
<hr />
<h1><a name="install_perl_on_cygwin">INSTALL PERL ON CYGWIN</a></h1>
<p>This will install Perl, including <em>man</em> pages.</p>
<pre>
  make install 2&gt;&amp;1 | tee log.make-install</pre>
<p>NOTE: If <code>STDERR</code> is redirected <code>make install</code> will <strong>not</strong> prompt
you to install <em>perl</em> into <em>/usr/bin</em>.</p>
<p>You may need to be <em>Administrator</em> to run <code>make install</code>.  If you
are not, you must have write access to the directories in question.</p>
<p>Information on installing the Perl documentation in HTML format can be
found in the <em>INSTALL</em> document.</p>
<p>
</p>
<hr />
<h1><a name="manifest_on_cygwin">MANIFEST ON CYGWIN</a></h1>
<p>These are the files in the Perl release that contain references to Cygwin.
These very brief notes attempt to explain the reason for all conditional
code.  Hopefully, keeping this up to date will allow the Cygwin port to
be kept as clean as possible (listing not updated yet).</p>
<dl>
<dt><strong><a name="item_documentation">Documentation</a></strong>

<dd>
<pre>
  INSTALL README.cygwin README.win32 MANIFEST
  Changes Changes5.005 Changes5.004 Changes5.6
  pod/perl.pod pod/<a href="../../lib/Pod/perlport.html">perlport</a>.pod pod/<a href="../../lib/Pod/perlfaq3.html">perlfaq3</a>.pod
  pod/<a href="../../lib/Pod/perldelta.html">perldelta</a>.pod pod/<a href="../../lib/Pod/perl5004delta.html">perl5004delta</a>.pod pod/<a href="../../lib/Pod/perl56delta.html">perl56delta</a>.pod
  pod/<a href="../../lib/Pod/perlhist.html">perlhist</a>.pod pod/<a href="../../lib/Pod/perlmodlib.html">perlmodlib</a>.pod perl/buildtoc pod/<a href="../../lib/Pod/perltoc.html">perltoc</a>.pod</pre>
</dd>
<dt><strong><a name="item_build_2c_configure_2c_make_2c_install">Build, Configure, Make, Install</a></strong>

<dd>
<pre>
  cygwin/Makefile.SHs
  cygwin/ld2.in
  cygwin/perlld.in
  ext/IPC/SysV/hints/cygwin.pl
  ext/NDBM_File/hints/cygwin.pl
  ext/ODBM_File/hints/cygwin.pl
  hints/cygwin.sh
  Configure             - help finding hints from uname,
                          shared libperl required for dynamic loading
  Makefile.SH           - linklibperl
  Porting/patchls       - cygwin in port list
  installman            - man pages with :: translated to .
  installperl           - install dll/ld2/perlld, install to pods
  makedepend.SH         - uwinfix</pre>
</dd>
<dt><strong><a name="item_tests">Tests</a></strong>

<dd>
<pre>
  t/io/tell.t           - binmode
  t/lib/b.t             - ignore Cwd from os_extras
  t/lib/glob-basic.t    - Win32 directory list access differs from read mode
  t/op/magic.t          - $^X/symlink WORKAROUND, s/.exe//
  t/op/stat.t           - no /dev, skip Win32 ftCreationTime quirk
                          (cache manager sometimes preserves ctime of file
                          previously created and deleted), no -u (setuid)
  t/lib/cygwin.t        - builtin cygwin function tests</pre>
</dd>
<dt><strong><a name="item_compiled_perl_source">Compiled Perl Source</a></strong>

<dd>
<pre>
  EXTERN.h              - __declspec(dllimport)
  XSUB.h                - __declspec(dllexport)
  cygwin/cygwin.c       - os_extras (getcwd, spawn, Cygwin::winpid_to_pid, 
                          Cygwin::pid_to_winpid)
  perl.c                - os_extras
  perl.h                - binmode
  doio.c                - win9x can not rename a file when it is open
  pp_sys.c              - do not define h_errno, pp_system with spawn
  util.c                - use setenv</pre>
</dd>
<dt><strong><a name="item_compiled_module_source">Compiled Module Source</a></strong>

<dd>
<pre>
  ext/POSIX/POSIX.xs    - tzname defined externally
  ext/SDBM_File/sdbm/pair.c
                        - EXTCONST needs to be redefined from EXTERN.h
  ext/SDBM_File/sdbm/sdbm.c
                        - binary open</pre>
</dd>
<dt><strong><a name="item_perl_modules_2fscripts">Perl Modules/Scripts</a></strong>

<dd>
<pre>
  lib/Cwd.pm            - hook to internal Cwd::cwd
  lib/ExtUtils/MakeMaker.pm
                        - require MM_Cygwin.pm
  lib/ExtUtils/MM_Cygwin.pm
                        - canonpath, cflags, manifypods, perl_archive
  lib/File/Find.pm      - on remote drives stat() always sets st_nlink to 1
  lib/File/Spec/Unix.pm - preserve //unc
  lib/File/Temp.pm      - no directory sticky bit
  lib/perl5db.pl        - use stdin not /dev/tty
  utils/<a href="../../lib/Pod/perldoc.html">perldoc</a>.PL      - version comment</pre>
</dd>
</dl>
<p>
</p>
<hr />
<h1><a name="bugs_on_cygwin">BUGS ON CYGWIN</a></h1>
<p>Support for swapping real and effective user and group IDs is incomplete.
On WinNT Cygwin provides <code>setuid()</code>, <code>seteuid()</code>, <code>setgid()</code> and <code>setegid()</code>.
However, additional Cygwin calls for manipulating WinNT access tokens
and security contexts are required.</p>
<p>
</p>
<hr />
<h1><a name="authors">AUTHORS</a></h1>
<p>Charles Wilson &lt;<a href="mailto:cwilson@ece.gatech.edu">cwilson@ece.gatech.edu</a>&gt;,
Eric Fifer &lt;<a href="mailto:egf7@columbia.edu">egf7@columbia.edu</a>&gt;,
alexander smishlajev &lt;<a href="mailto:als@turnhere.com">als@turnhere.com</a>&gt;,
Steven Morlock &lt;<a href="mailto:newspost@morlock.net">newspost@morlock.net</a>&gt;,
Sebastien Barre &lt;<a href="mailto:Sebastien.Barre@utc.fr">Sebastien.Barre@utc.fr</a>&gt;,
Teun Burgers &lt;<a href="mailto:burgers@ecn.nl">burgers@ecn.nl</a>&gt;,
Gerrit P. Haase &lt;<a href="mailto:gp@familiehaase.de">gp@familiehaase.de</a>&gt;.</p>
<p>
</p>
<hr />
<h1><a name="history">HISTORY</a></h1>
<p>Last updated: 2005-02-11</p>

</body>

</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?