⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit-posix.html

📁 Scheme跨平台编译器
💻 HTML
📖 第 1 页 / 共 4 页
字号:
[procedure] (stat-symlink? FILENAME)[procedure] (stat-socket? FILENAME)</pre><p>These procedures return <tt>#t</tt> if the <tt>FILENAME</tt> given is of the  appropriate type.</p><a name="changing-file-attributes"></a><h2>Changing file attributes</h2><a name="file-truncate"></a><h3>file-truncate</h3><pre>[procedure] (file-truncate FILE OFFSET)</pre><p>Truncates the file <tt>FILE</tt> to the length <tt>OFFSET</tt>, which should be an integer. If the file-size is smaller or equal to <tt>OFFSET</tt> then nothing is done.  <tt>FILE</tt> should be a filename or a file-descriptor.</p><a name="set-file-position"></a><h3>set-file-position!</h3><pre>[procedure] (set-file-position! FILE POSITION [WHENCE])[procedure] (set! (file-position FILE) POSITION)</pre><p>Sets the current read/write position of <tt>FILE</tt> to <tt>POSITION</tt>, which should be an exact integer. <tt>FILE</tt> should be a port or a file-descriptor.  <tt>WHENCE</tt> specifies how the position is to interpreted and should be one of the values <tt>seek/set, seek/cur</tt> and <tt>seek/end</tt>. It defaults to <tt>seek/set</tt>.</p><p>Exceptions: <tt>(exn bounds)</tt>, <tt>(exn i/o file)</tt></p><a name="change-file-mode"></a><h3>change-file-mode</h3><pre>[procedure] (change-file-mode FILENAME MODE)</pre><p>Changes the current file mode of the file named <tt>FILENAME</tt> to <tt>MODE</tt> using the <tt>chmod()</tt> system call.  The <tt>perm/...</tt> variables contain the various permission bits and can be combinded with the <tt>bitwise-ior</tt> procedure.</p><a name="change-file-owner"></a><h3>change-file-owner</h3><pre>[procedure] (change-file-owner FILENAME UID GID)</pre><p>Changes the owner information of the file named <tt>FILENAME</tt> to the user- and group-ids <tt>UID</tt> and <tt>GID</tt> (which should be exact integers) using the <tt>chown()</tt> system call.</p><a name="processes"></a><h2>Processes</h2><a name="current-process-id"></a><h3>current-process-id</h3><pre>[procedure] (current-process-id)</pre><p>Returns the process ID of the current process.</p><a name="parent-process-id"></a><h3>parent-process-id</h3><pre>[procedure] (parent-process-id)</pre><p>Returns the process ID of the parent of the current process.</p><a name="process-group-id"></a><h3>process-group-id</h3><pre>[procedure] (process-group-id PID)</pre><p>Returns the process group ID of the process specified by <tt>PID</tt>.</p><a name="process-execute"></a><h3>process-execute</h3><pre>[procedure] (process-execute PATHNAME [ARGUMENT-LIST [ENVIRONMENT-LIST]])</pre><p>Creates a new child process and replaces the running process with it using the C library function <tt>execvp(3)</tt>. If the optional argument <tt>ARGUMENT-LIST</tt> is given, then it should contain a list of strings which are passed as arguments to the subprocess. If the optional argument <tt>ENVIRONMENT-LIST</tt> is supplied, then the library function <tt>execve(2)</tt> is used, and the environment passed in <tt>ENVIRONMENT-LIST</tt> (which should be of the form <tt>("&lt;NAME&gt;=&lt;VALUE&gt;" ...)</tt> is given to the invoked process. Note that <tt>execvp(3)</tt> respects the current setting of the <tt>PATH</tt> environment variable while <tt>execve(3)</tt> does not.</p><a name="process-fork"></a><h3>process-fork</h3><pre>[procedure] (process-fork [THUNK])</pre><p>Creates a new child process with the UNIX system call <tt>fork()</tt>. Returns either the PID of the child process or 0. If <tt>THUNK</tt> is given, then the child process calls it as a procedure with no arguments and terminates.</p><a name="process-run"></a><h3>process-run</h3><pre>[procedure] (process-run COMMANDLINE])[procedure] (process-run COMMAND ARGUMENT-LIST)</pre><p>Creates a new child process. The PID of the new process is returned.</p><ul><li>The single parameter version passes the <tt>COMMANDLINE</tt> to the system shell, so usual argument expansion can take place.</li><li>The multiple parameter version directly invokes the <tt>COMMAND</tt> with the <tt>ARGUMENT-LIST</tt>.</li></ul><a name="process-signal"></a><h3>process-signal</h3><pre>[procedure] (process-signal PID [SIGNAL])</pre><p>Sends <tt>SIGNAL</tt> to the process with the id <tt>PID</tt> using the UNIX system call <tt>kill()</tt>. <tt>SIGNAL</tt> defaults to the value of the variable <tt>signal/term</tt>.</p><a name="process-wait"></a><h3>process-wait</h3><pre>[procedure] (process-wait [PID [NOHANG]])</pre><p>Suspends the current process until the child process with the id <tt>PID</tt> has terminated using the UNIX system call <tt>waitpid()</tt>. If <tt>PID</tt> is not given, then this procedure waits for any child process. If <tt>NOHANG</tt> is given and not <tt>#f</tt> then the current process is not suspended.  This procedure returns three values:</p><ul><li><tt>PID</tt> or 0, if <tt>NOHANG</tt> is true and the child process has not terminated yet.</li><li><tt>#t</tt> if the process exited normally or <tt>#f</tt> otherwise.</li><li>either the exit status, if the process terminated normally or the signal number that terminated/stopped the process.</li></ul><a name="process"></a><h3>process</h3><pre>[procedure] (process COMMANDLINE)[procedure] (process COMMAND ARGUMENT-LIST [ENVIRONMENT-LIST])</pre><p>Creates a subprocess and returns three values: an input port from which data written by the sub-process can be read, an output port from which any data written to will be received as input in the sub-process and the process-id of the started sub-process. Blocking reads and writes to or from the ports returned by <tt>process</tt> only block the current thread, not other threads executing concurrently.</p><ul><li>The single parameter version passes the string <tt>COMMANDLINE</tt> to the host-system's shell that is invoked as a subprocess.</li><li>The multiple parameter version directly invokes the <tt>COMMAND</tt> as a subprocess. The <tt>ARGUMENT-LIST</tt> is directly passed, as is <tt>ENVIRONMENT-LIST</tt>.</li></ul><p>Not using the shell may be preferrable for security reasons.</p><a name="process"></a><h3>process*</h3><pre>[procedure] (process* COMMANDLINE)[procedure] (process* COMMAND ARGUMENT-LIST [ENVIRONMENT-LIST])</pre><p>Like <tt>process</tt> but returns 4 values: an input port from which data written by the sub-process can be read, an output port from which any data written to will be received as input in the sub-process, the process-id of the started sub-process, and an input port from which data written by the sub-process to <tt>stderr</tt> can be read.</p><a name="sleep"></a><h3>sleep</h3><pre>[procedure] (sleep SECONDS)</pre><p>Puts the process to sleep for <tt>SECONDS</tt>. Returns either 0 if the time has completely elapsed, or the number of remaining seconds, if a signal occurred.</p><a name="create-session"></a><h3>create-session</h3><pre>[procedure] (create-session)</pre><p>Creates a new session if the calling process is not a process group leader and returns the session ID.</p><a name="hard-and-symbolic-links"></a><h2>Hard and symbolic links</h2><a name="symbolic-link"></a><h3>symbolic-link?</h3><pre>[procedure] (symbolic-link? FILENAME)</pre><p>Returns true, if <tt>FILENAME</tt> names a symbolic link.</p><a name="create-symbolic-link"></a><h3>create-symbolic-link</h3><pre>[procedure] (create-symbolic-link OLDNAME NEWNAME)</pre><p>Creates a symbolic link with the filename <tt>NEWNAME</tt> that points to the file named <tt>OLDNAME</tt>.</p><a name="read-symbolic-link"></a><h3>read-symbolic-link</h3><pre>[procedure] (read-symbolic-link FILENAME)</pre><p>Returns the filename to which the symbolic link <tt>FILENAME</tt> points.</p><a name="file-link"></a><h3>file-link</h3><pre>[procedure] (file-link OLDNAME NEWNAME)</pre><p>Creates a hard link from <tt>OLDNAME</tt> to <tt>NEWNAME</tt> (both strings).</p><a name="retrieving-user-group-information"></a><h2>Retrieving user &amp; group information</h2><a name="current-user-id"></a><h3>current-user-id</h3><pre>[procedure] (current-user-id)[setter] (set! (current-user-id) UID)</pre><p>Get or set the real user-id of the current process.</p><a name="current-effective-user-id"></a><h3>current-effective-user-id</h3><pre>[procedure] (current-effective-user-id)[setter] (set! (current-effective-user-id) UID)</pre><p>Get or set the effective user-id of the current process.</p><a name="user-information"></a><h3>user-information</h3><pre>[procedure] (user-information USER [AS-VECTOR])</pre><p>If <tt>USER</tt> specifes a valid username (as a string) or user ID, then the user database is consulted and a list of 7 values are returned: the user-name, the encrypted password, the user ID, the group ID, a user-specific string, the home directory and the default shell. When <tt>AS-VECTOR</tt> is <tt>#t</tt> a vector of 7 elements is returned instead of a list. If no user with this name or id then <tt>#f</tt> is returned.</p><a name="current-group-id"></a><h3>current-group-id</h3><pre>[procedure] (current-group-id)[setter] (set! (current-group-id) GID)</pre><p>Get or set the real group-id of the current process.</p><a name="current-effective-group-id"></a><h3>current-effective-group-id</h3><pre>[procedure] (current-effective-group-id)[setter] (set! (current-effective-group-id) GID)</pre><p>Get or set the effective group-id of the current process. ID can be found, then <tt>#f</tt> is returned.</p><a name="group-information"></a><h3>group-information</h3><pre>[procedure] (group-information GROUP)</pre><p>If <tt>GROUP</tt> specifies a valid group-name or group-id, then this procedure returns a list of four values: the group-name, the encrypted group password, the group ID and a list of the names of all group members. If no group with the given name or ID exists, then <tt>#f</tt> is returned.</p><a name="get-groups"></a><h3>get-groups</h3><pre>[procedure] (get-groups)</pre><p>Returns a list with the supplementary group IDs of the current user.</p><a name="changing-user-group-information"></a><h2>Changing user &amp; group information</h2><a name="set-groups"></a><h3>set-groups!</h3><pre>[procedure] (set-groups! GIDLIST)</pre><p>Sets the supplementrary group IDs of the current user to the IDs given in the list <tt>GIDLIST</tt>.</p><p>Only the superuser may invoke this procedure.</p><a name="initialize-groups"></a><h3>initialize-groups</h3><pre>[procedure] (initialize-groups USERNAME BASEGID)</pre><p>Sets the supplementrary group IDs of the current user to the IDs from the user with name <tt>USERNAME</tt> (a string), including <tt>BASEGID</tt>.</p><p>Only the superuser may invoke this procedure.</p><a name="set-process-group-id"></a><h3>set-process-group-id!</h3><pre>[procedure] (set-process-group-id! PID PGID)[setter] (set! (process-group-id PID) PGID)</pre><p>Sets the process group ID of the process specifed by <tt>PID</tt> to <tt>PGID</tt>.</p><a name="record-locking"></a><h2>Record locking</h2><a name="file-lock"></a><h3>file-lock</h3><pre>[procedure] (file-lock PORT [START [LEN]])</pre><p>Locks the file associated with <tt>PORT</tt> for reading or writing (according to whether <tt>PORT</tt> is an input- or output-port). <tt>START</tt> specifies the starting position in the file to be locked and defaults to 0. <tt>LEN</tt> specifies the length of the portion to be locked and defaults to <tt>#t</tt>, which means the complete file. <tt>file-lock</tt> returns a <em>lock</em>-object.</p><a name="file-lock-blocking"></a><h3>file-lock/blocking</h3><pre>[procedure] (file-lock/blocking PORT [START [LEN]])</pre><p>Similar to <tt>file-lock</tt>, but if a lock is held on the file, the current process blocks (including all threads) until the lock is released.</p><a name="file-test-lock"></a><h3>file-test-lock</h3><pre>[procedure] (file-test-lock PORT [START [LEN]])</pre><p>Tests whether the file associated with <tt>PORT</tt> is locked for reading or writing (according to whether <tt>PORT</tt> is an input- or output-port) and returns either <tt>#f</tt> or the process-id of the locking process.</p><a name="file-unlock"></a><h3>file-unlock</h3><pre>[procedure] (file-unlock LOCK)</pre><p>Unlocks the previously locked portion of a file given in <tt>LOCK</tt>.</p><a name="signal-handling"></a><h2>Signal handling</h2><a name="set-alarm"></a><h3>set-alarm!</h3><pre>[procedure] (set-alarm! SECONDS)</pre><p>Sets an internal timer to raise the <tt>signal/alrm</tt> after <tt>SECONDS</tt> are elapsed.  You can use the <tt>set-signal-handler!</tt> procedure to write a handler for this signal.</p><a name="set-signal-handler"></a><h3>set-signal-handler!</h3><pre>[procedure] (set-signal-handler! SIGNUM PROC)</pre><p>Establishes the procedure of one argument <tt>PROC</tt> as the handler for the signal with the code <tt>SIGNUM</tt>. <tt>PROC</tt> is called with the signal number as its sole argument. If the argument <tt>PROC</tt> is <tt>#f</tt> then any signal handler will be removed, and the corresponding signal set to <tt>SIG_IGN</tt>.</p><p>Note that is is unspecified in which thread of execution the signal handler will be invoked.</p><a name="signal-handler"></a><h3>signal-handler</h3><pre>[procedure] (signal-handler SIGNUM)</pre><p>Returns the signal handler for the code <tt>SIGNUM</tt> or <tt>#f</tt>.</p><a name="set-signal-mask"></a><h3>set-signal-mask!</h3><pre>[procedure] (set-signal-mask! SIGLIST)</pre><p>Sets the signal mask of the current process to block all signals given in the list <tt>SIGLIST</tt>.  Signals masked in that way will not be delivered to the current process.</p><a name="signal-mask"></a><h3>signal-mask</h3><pre>[procedure] (signal-mask)</pre><p>Returns the signal mask of the current process.</p><a name="signal-masked"></a><h3>signal-masked?</h3><pre>[procedure] (signal-masked? SIGNUM)</pre><p>Returns whether the signal for the code <tt>SIGNUM</tt> is currently masked.</p><a name="signal-mask"></a><h3>signal-mask!</h3><pre>[procedure] (signal-mask! SIGNUM)</pre><p>Masks (blocks) the signal for the code <tt>SIGNUM</tt>.</p><a name="signal-unmask"></a><h3>signal-unmask!</h3><pre>[procedure] (signal-unmask! SIGNUM)</pre><p>Unmasks (unblocks) the signal for the code <tt>SIGNUM</tt>.</p><a name="signal-term"></a><h3>signal/term</h3><a name="signal-kill"></a><h3>signal/kill</h3><a name="signal-int"></a><h3>signal/int</h3><a name="signal-hup"></a><h3>signal/hup</h3><a name="signal-fpe"></a><h3>signal/fpe</h3><a name="signal-ill"></a><h3>signal/ill</h3><a name="signal-segv"></a><h3>signal/segv</h3><a name="signal-abrt"></a><h3>signal/abrt</h3><a name="signal-trap"></a><h3>signal/trap</h3><a name="signal-quit"></a><h3>signal/quit</h3><a name="signal-alrm"></a><h3>signal/alrm</h3><a name="signal-vtalrm"></a><h3>signal/vtalrm</h3><a name="signal-prof"></a><h3>signal/prof</h3><a name="signal-io"></a><h3>signal/io</h3><a name="signal-urg"></a><h3>signal/urg</h3><a name="signal-chld"></a><h3>signal/chld</h3><a name="signal-cont"></a><h3>signal/cont</h3><a name="signal-stop"></a><h3>signal/stop</h3><a name="signal-tstp"></a><h3>signal/tstp</h3><a name="signal-pipe"></a><h3>signal/pipe</h3><a name="signal-xcpu"></a><h3>signal/xcpu</h3><a name="signal-xfsz"></a><h3>signal/xfsz</h3><a name="signal-usr1"></a><h3>signal/usr1</h3><a name="signal-usr2"></a><h3>signal/usr2</h3><a name="signal-winch"></a><h3>signal/winch</h3><p>These variables contain signal codes for use with <tt>process-signal</tt>,  <tt>set-signal-handler!</tt>,  <tt>signal-handler</tt>,  <tt>signal-masked?</tt>,  <tt>signal-mask!</tt>,  or <tt>signal-unmask!</tt>.</p><a name="environment-access"></a><h2>Environment access</h2><a name="current-environment"></a><h3>current-environment</h3><pre>[procedure] (current-environment)</pre><p>Returns a association list of the environment variables and their current values.</p><a name="setenv"></a><h3>setenv</h3><pre>[procedure] (setenv VARIABLE VALUE)</pre><p>Sets the environment variable named <tt>VARIABLE</tt> to <tt>VALUE</tt>. Both arguments should be strings. If the variable is not defined in the environment, a new definition is created.</p><a name="unsetenv"></a><h3>unsetenv</h3><pre>[procedure] (unsetenv VARIABLE)</pre><p>Removes the definition of the environment variable <tt>VARIABLE</tt> from the environment of the current process. If the variable is not defined, nothing happens.</p><a name="memory-mapped-i-o"></a><h2>Memory mapped I/O</h2><a name="memory-mapped-file"></a><h3>memory-mapped-file?</h3><pre>[pocedure] (memory-mapped-file? X)</pre><p>Returns <tt>#t</tt>, if <tt>X</tt> is an object representing a memory mapped file, or <tt>#f</tt> otherwise.</p><a name="map-file-to-memory"></a><h3>map-file-to-memory</h3><pre>[procedure] (map-file-to-memory ADDRESS LEN PROTECTION FLAG FILENO [OFFSET])</pre><p>Maps a section of a file to memory using the C function <tt>mmap()</tt>.  <tt>ADDRESS</tt> should be a foreign pointer object or <tt>#f</tt>; <tt>LEN</tt> specifies the size of the section to be mapped; <tt>PROTECTION</tt> should be one or more of the flags <tt>prot/read, prot/write, prot/exec</tt> or <tt>prot/none</tt> <strong>bitwise-ior</strong>ed together; <tt>FLAG</tt> should be one or more of the flags <tt>map/fixed, map/shared, map/private, map/anonymous</tt> or <tt>map/file</tt>; <tt>FILENO</tt> should be the file-descriptor of the mapped file. The optional argument <tt>OFFSET</tt> gives the offset of the section of the file to be mapped and defaults to 0. This procedure returns an object representing the mapped file section.  The procedure <tt>move-memory!</tt> can be used to access the mapped memory.</p><a name="memory-mapped-file-pointer"></a><h3>memory-mapped-file-pointer</h3><pre>[procedure] (memory-mapped-file-pointer MMAP)</pre><p>Returns a machine pointer to the start of the memory region to which the file is mapped.</p><a name="unmap-file-from-memory"></a><h3>unmap-file-from-memory</h3><pre>[procedure] (unmap-file-from-memory MMAP [LEN])</pre><p>Unmaps the section of a file mapped to memory using the C function <tt>munmap()</tt>.  <tt>MMAP</tt> should be a mapped file as returned by the procedure <tt>map-file-to-memory</tt>.  The optional argument <tt>LEN</tt> specifies the length of the section to be unmapped and defaults to the complete length given when the file was mapped.</p><a name="date-and-time-routines"></a><h2>Date and time routines</h2><a name="seconds-local-time"></a><h3>seconds&rarr;local-time</h3><pre>[procedure] (seconds-&gt;local-time SECONDS)</pre><p>Breaks down the time value represented in <tt>SECONDS</tt> into a 10 element vector of the form <tt>#(seconds minutes hours mday month year wday yday dstflag timezone)</tt>, in the following format:</p><dl><dt>seconds (0)</dt><dd>the number of seconds after the minute (0 - 59)</dd><dt>minutes (1)</dt><dd>the number of minutes after the hour (0 - 59)</dd><dt>hours (2)</dt><dd>the number of hours past midnight (0 - 23)</dd><dt>mday (3)</dt><dd>the day of the month (1 - 31)</dd><dt>month (4)</dt><dd>the number of months since january (0 - 11)</dd><dt>year (5)</dt><dd>the number of years since 1900</dd><dt>wday (6)</dt><dd>the number of days since Sunday (0 - 6)</dd><dt>yday (7)</dt><dd>the number of days since January 1 (0 - 365)</dd><dt>dstflag (8)</dt><dd>a flag that is true if Daylight Saving Time is in effect at the time described.</dd><dt>timezone (9)</dt><dd>the difference between UTC and the latest local standard time, in seconds west of UTC.</dd></dl><a name="local-time-seconds"></a><h3>local-time&rarr;seconds</h3><pre>[procedure] (local-time-&gt;seconds VECTOR)</pre><p>Converts the ten-element vector <tt>VECTOR</tt> representing the time value relative to the current timezone into the number of seconds since the first of January, 1970 UTC.</p><a name="local-timezone-abbreviation"></a><h3>local-timezone-abbreviation</h3><pre>[procedure] (local-timezone-abbreviation)</pre><p>Returns the abbreviation for the local timezone as a string.</p><a name="seconds-string"></a><h3>seconds&rarr;string</h3><pre>[procedure] (seconds-&gt;string SECONDS)</pre><p>Converts the local time represented in <tt>SECONDS</tt> into a string of the form <tt>"Tue May 21 13:46:22 1991"</tt>.</p><a name="seconds-utc-time"></a><h3>seconds&rarr;utc-time</h3><pre>[procedure] (seconds-&gt;utc-time SECONDS)</pre><p>Similar to <tt>seconds-&gt;local-time</tt>, but interpretes <tt>SECONDS</tt> as UTC time.</p><a name="utc-time-seconds"></a><h3>utc-time&rarr;seconds</h3><pre>[procedure] (utc-time-&gt;seconds VECTOR)</pre><p>Converts the ten-element vector <tt>VECTOR</tt> representing the UTC time value into the number of seconds since the first of January, 1970 UTC.</p><a name="time-string"></a><h3>time&rarr;string</h3><pre>[procedure] (time-&gt;string VECTOR)</pre><p>Converts the broken down time represented in the 10 element vector <tt>VECTOR</tt> into a string of the form <tt>"Tue May 21 13:46:22 1991"</tt>.</p><a name="raw-exit"></a><h2>Raw exit</h2><a name="exit"></a><h3>_exit</h3><pre>[procedure] (_exit [CODE])</pre><p>Exits the current process without flushing any buffered output (using the C function <tt>_exit</tt>).  Note that the <tt>exit-handler</tt> is not called when this procedure is invoked. The optional return-code <tt>CODE</tt> defaults to <tt>0</tt>.</p><a name="errno-values"></a><h2>ERRNO values</h2><a name="errno-perm"></a><h3>errno/perm</h3><a name="errno-noent"></a><h3>errno/noent</h3><a name="errno-srch"></a><h3>errno/srch</h3><a name="errno-intr"></a><h3>errno/intr</h3><a name="errno-io"></a><h3>errno/io</h3><a name="errno-noexec"></a><h3>errno/noexec</h3><a name="errno-badf"></a><h3>errno/badf</h3><a name="errno-child"></a><h3>errno/child</h3><a name="errno-nomem"></a><h3>errno/nomem</h3><a name="errno-acces"></a><h3>errno/acces</h3><a name="errno-fault"></a><h3>errno/fault</h3><a name="errno-busy"></a><h3>errno/busy</h3><a name="errno-notdir"></a><h3>errno/notdir</h3><a name="errno-isdir"></a><h3>errno/isdir</h3><a name="errno-inval"></a><h3>errno/inval</h3><a name="errno-mfile"></a><h3>errno/mfile</h3><a name="errno-nospc"></a><h3>errno/nospc</h3><a name="errno-spipe"></a><h3>errno/spipe</h3><a name="errno-pipe"></a><h3>errno/pipe</h3><a name="errno-again"></a><h3>errno/again</h3><a name="errno-rofs"></a><h3>errno/rofs</h3><a name="errno-exist"></a><h3>errno/exist</h3><a name="errno-wouldblock"></a><h3>errno/wouldblock</h3><p>These variables contain error codes as returned by <tt>errno</tt>.</p><a name="finding-files"></a><h2>Finding files</h2><a name="find-files"></a><h3>find-files</h3><pre>[procedure] (find-files DIRECTORY PREDICATE [ACTION [IDENTITY [LIMIT]]])</pre><p>Recursively traverses the contents of <tt>DIRECTORY</tt> (which should be a string) and invokes the procedure <tt>ACTION</tt> for all files in which the procedure <tt>PREDICATE</tt> is true.  <tt>PREDICATE</tt> may me a procedure of one argument or a regular-expression string. <tt>ACTION</tt> should be a procedure of two arguments: the currently encountered file and the result of the previous invocation of <tt>ACTION</tt>, or, if this is the first invocation, the value of <tt>IDENTITY</tt>. <tt>ACTION</tt> defaults to <tt>cons</tt>, <tt>IDENTITY</tt> defaults to <tt>()</tt>.  <tt>LIMIT</tt> should be a procedure of one argument that is called for each nested directory and which should return true, if that directory is to be traversed recursively. <tt>LIMIT</tt> may also be an exact integer that gives the maximum recursion depth. For example, a depth of <tt>0</tt> means that only files in the top-level, specified directory are to be traversed. In this case, all nested directories are ignored.  <tt>LIMIT</tt> may also be <tt>#f</tt> (the default), which is equivalent to <tt>(constantly #t)</tt>.</p><p>Note that <tt>ACTION</tt> is called with the full pathname of each file, including the directory prefix.</p><a name="getting-the-hostname-and-system-information"></a><h2>Getting the hostname and system information</h2><a name="get-host-name"></a><h3>get-host-name</h3><pre>[procedure] (get-host-name)</pre><p>Returns the hostname of the machine that this process is running on.</p><a name="system-information"></a><h3>system-information</h3><pre>[procedure] (system-information)</pre><p>Invokes the UNIX system call <tt>uname()</tt> and returns a list of 5 values: system-name, node-name, OS release, OS version and machine.</p><a name="setting-the-file-buffering-mode"></a><h2>Setting the file buffering mode</h2><a name="set-buffering-mode"></a><h3>set-buffering-mode!</h3><pre>[procedure] (set-buffering-mode! PORT MODE [BUFSIZE])</pre><p>Sets the buffering-mode for the file associated with <tt>PORT</tt> to <tt>MODE</tt>, which should be one of the keywords <tt>#:full</tt>, <tt>#:line</tt> or <tt>#:none</tt>. If <tt>BUFSIZE</tt> is specified it determines the size of the buffer to be used (if any).</p><a name="terminal-ports"></a><h2>Terminal ports</h2><a name="terminal-name"></a><h3>terminal-name</h3><pre>[procedure] (terminal-name PORT)</pre><p>Returns the name of the terminal that is connected to <tt>PORT</tt>.</p><a name="terminal-port"></a><h3>terminal-port?</h3><pre>[procedure] (terminal-port? PORT)</pre><p>Returns <tt>#t</tt> if <tt>PORT</tt> is connected to a terminal and <tt>#f</tt> otherwise.</p><a name="how-scheme-procedures-relate-to-unix-c-functions"></a><h2>How Scheme procedures relate to UNIX C functions</h2><dl><dt><tt>change-directory</tt></dt><dd><tt>chdir</tt></dd><dt><tt>change-file-mode</tt></dt><dd><tt>chmod</tt></dd><dt><tt>change-file-owner</tt></dt><dd><tt>chown</tt></dd><dt><tt>create-directory</tt></dt><dd><tt>mkdir</tt></dd><dt><tt>create-fifo</tt></dt><dd><tt>mkfifo</tt></dd><dt><tt>create-pipe</tt></dt><dd><tt>pipe</tt></dd><dt><tt>create-session</tt></dt><dd><tt>setsid</tt></dd><dt><tt>create-symbolic-link</tt></dt><dd><tt>link</tt></dd><dt><tt>current-directory</tt></dt><dd><tt>curdir</tt></dd><dt><tt>current-effective-groupd-id</tt></dt><dd><tt>getegid</tt></dd><dt><tt>current-effective-user-id</tt></dt><dd><tt>geteuid</tt></dd><dt><tt>current-group-id</tt></dt><dd><tt>getgid</tt></dd><dt><tt>current-parent-id</tt></dt><dd><tt>getppid</tt></dd><dt><tt>current-process-id</tt></dt><dd><tt>getpid</tt></dd><dt><tt>current-user-id</tt></dt><dd><tt>getuid</tt></dd><dt><tt>delete-directory</tt></dt><dd><tt>rmdir</tt></dd><dt><tt>duplicate-fileno</tt></dt><dd><tt>dup/dup2</tt></dd><dt><tt>_exit</tt></dt><dd><tt>_exit</tt></dd><dt><tt>file-close</tt></dt><dd><tt>close</tt></dd><dt><tt>file-access-time</tt></dt><dd><tt>stat</tt></dd><dt><tt>file-change-time</tt></dt><dd><tt>stat</tt></dd><dt><tt>file-modification-time</tt></dt><dd><tt>stat</tt></dd><dt><tt>file-execute-access?</tt></dt><dd><tt>access</tt></dd><dt><tt>file-open</tt></dt><dd><tt>open</tt></dd><dt><tt>file-lock</tt></dt><dd><tt>fcntl</tt></dd><dt><tt>file-position</tt></dt><dd><tt>ftell/lseek</tt></dd><dt><tt>file-read</tt></dt><dd><tt>read</tt></dd><dt><tt>file-read-access?</tt></dt><dd><tt>access</tt></dd><dt><tt>file-select</tt></dt><dd><tt>select</tt></dd><dt><tt>file-control</tt></dt><dd><tt>fcntl</tt></dd><dt><tt>file-stat</tt></dt><dd><tt>stat</tt></dd><dt><tt>file-test-lock</tt></dt><dd><tt>fcntl</tt></dd><dt><tt>file-truncate</tt></dt><dd><tt>truncate/ftruncate</tt></dd><dt><tt>file-unlock</tt></dt><dd><tt>fcntl</tt></dd><dt><tt>file-write</tt></dt><dd><tt>write</tt></dd><dt><tt>file-write-access?</tt></dt><dd><tt>access</tt></dd><dt><tt>get-groups</tt></dt><dd><tt>getgroups</tt></dd><dt><tt>get-host-name</tt></dt><dd><tt>gethostname</tt></dd><dt><tt>initialize-groups</tt></dt><dd><tt>initgroups</tt></dd><dt><tt>local-time-&gt;seconds</tt></dt><dd><tt>mktime</tt></dd><dt><tt>local-timezone-abbreviation</tt></dt><dd><tt>localtime</tt></dd><dt><tt>map-file-to-memory</tt></dt><dd><tt>mmap</tt></dd><dt><tt>open-input-file*</tt></dt><dd><tt>fdopen</tt></dd><dt><tt>open-output-file*</tt></dt><dd><tt>fdopen</tt></dd><dt><tt>open-input-pipe</tt></dt><dd><tt>popen</tt></dd><dt><tt>open-output-pipe</tt></dt><dd><tt>popen</tt></dd><dt><tt>port-&gt;fileno</tt></dt><dd><tt>fileno</tt></dd><dt><tt>process-execute</tt></dt><dd><tt>execvp</tt></dd><dt><tt>process-fork</tt></dt><dd><tt>fork</tt></dd><dt><tt>process-group-id</tt></dt><dd><tt>getpgid</tt></dd><dt><tt>process-signal</tt></dt><dd><tt>kill</tt></dd><dt><tt>process-wait</tt></dt><dd><tt>waitpid</tt></dd><dt><tt>close-input-pipe</tt></dt><dd><tt>pclose</tt></dd><dt><tt>close-output-pipe</tt></dt><dd><tt>pclose</tt></dd><dt><tt>read-symbolic-link</tt></dt><dd><tt>readlink</tt></dd><dt><tt>seconds-&gt;local-time</tt></dt><dd><tt>localtime</tt></dd><dt><tt>seconds-&gt;string</tt></dt><dd><tt>ctime</tt></dd><dt><tt>seconds-&gt;utc-time</tt></dt><dd><tt>gmtime</tt></dd><dt><tt>set-alarm!</tt></dt><dd><tt>alarm</tt></dd><dt><tt>set-buffering-mode!</tt></dt><dd><tt>setvbuf</tt></dd><dt><tt>set-file-position!</tt></dt><dd><tt>fseek/seek</tt></dd><dt><tt>set-groups!</tt></dt><dd><tt>setgroups</tt></dd><dt><tt>set-signal-mask!</tt></dt><dd><tt>sigprocmask</tt></dd><dt><tt>set-group-id!</tt></dt><dd><tt>setgid</tt></dd><dt><tt>set-process-group-id!</tt></dt><dd><tt>setpgid</tt></dd><dt><tt>set-user-id!</tt></dt><dd><tt>setuid</tt></dd><dt><tt>set-root-directory!</tt></dt><dd><tt>chroot</tt></dd><dt><tt>setenv</tt></dt><dd><tt>setenv/putenv</tt></dd><dt><tt>sleep</tt></dt><dd><tt>sleep</tt></dd><dt><tt>system-information</tt></dt><dd><tt>uname</tt></dd><dt><tt>terminal-name</tt></dt><dd><tt>ttyname</tt></dd><dt><tt>terminal-port?</tt></dt><dd><tt>isatty</tt></dd><dt><tt>time-&gt;string</tt></dt><dd><tt>asctime</tt></dd><dt><tt>unsetenv</tt></dt><dd><tt>putenv</tt></dd><dt><tt>unmap-file-from-memory</tt></dt><dd><tt>munmap</tt></dd><dt><tt>user-information</tt></dt><dd><tt>getpwnam/getpwuid</tt></dd><dt><tt>utc-time-&gt;seconds</tt></dt><dd><tt>timegm</tt></dd></dl><a name="windows-specific-notes"></a><h2>Windows specific notes</h2><p>Use of UTF8 encoded strings is for pathnames is not supported. Windows uses a 16-bit UNICODE encoding with special system calls for wide-character support. Only single-byte string encoding can be used.</p><a name="procedure-changes"></a><h3>Procedure Changes</h3><p>Exceptions to the above procedure definitions.</p><pre>[procedure] (create-pipe [MODE])</pre><p>The optional parameter <tt>MODE</tt>, default <tt>open/binary | open/noinherit</tt>. This can be <tt>open/binary</tt> or <tt>open/text</tt>, optionally or'ed with <tt>open/noinherit</tt>.</p><pre>[procedure] (process-wait [PID [NOHANG]])</pre><p><tt>process-wait</tt> always returns <tt>#t</tt> for a terminated process and only the exit status is available. (Windows does not provide signals as an interprocess communication method.)</p><pre>[procedure] (process-execute PATHNAME [ARGUMENT-LIST [ENVIRONMENT-LIST [EXACT-FLAG]]])[procedure] (process COMMAND ARGUMENT-LIST [ENVIRONMENT-LIST [EXACT-FLAG]])[procedure] (process* COMMAND ARGUMENT-LIST [ENVIRONMENT-LIST [EXACT-FLAG]])</pre><p>The optional parameter <tt>EXACT-FLAG</tt>, default <tt>#f</tt>. When <tt>#f</tt> any argument string with embedded whitespace will be wrapped in quotes. When <tt>#t</tt> no such wrapping occurs.</p><a name="unsupported-definitions"></a><h3>Unsupported Definitions</h3><p>The following definitions are not supported for native Windows builds (compiled with the Microsoft tools or with MinGW):</p><pre>open/noctty  open/nonblock  open/fsync  open/syncperm/isvtx  perm/isuid  perm/isgidfile-select file-controlsignal/... (except signal/term, signal/int, signal/fpe, signal/ill, signal/segv, signal/abrt, signal/break)set-signal-mask!  signal-mask  signal-masked?  signal-mask!  signal-unmask!user-information  group-information  get-groups  set-groups!  initialize-groupserrno/wouldblockchange-file-owner

⌨️ 快捷键说明

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