source: project/wiki/man/5/Module (chicken process-context) @ 34904

Last change on this file since 34904 was 34904, checked in by sjamaan, 4 years ago

man/5: Move the "exit" family of procedures from (chicken process-context) to (chicken base)

File size: 6.8 KB
Line 
1[[tags: manual]]
2[[toc:]]
3
4== Module (chicken process-context)
5
6This module provides access to the current process context.
7
8=== Information about the program's invocation
9
10==== argv
11
12<procedure>(argv)</procedure>
13
14Return a list of all supplied command-line arguments. The first item in
15the list is a string containing the name of the executing program. The
16other items are the arguments passed to the application. It depends on
17the host-shell whether arguments are expanded ('globbed') or not.
18
19=== command-line-arguments
20
21<parameter>(command-line-arguments)</parameter>
22
23Contains the list of arguments passed to this program, with the name of
24the program and any runtime options (all options starting with {{-:}})
25removed.
26
27==== executable-pathname
28
29<procedure>(executable-pathname)</procedure>
30
31Returns a full pathname of the currently-running executable, or {{#f}}
32if it couldn't be determined. When evaluating code in the interpreter,
33this will be a path to {{csi}}.
34
35=== program-name
36
37<parameter>(program-name)</parameter>
38
39The name of the currently executing program. This is equivalent to
40{{(car (argv))}} for compiled programs or the filename following the
41{{-script}} option in interpreted scripts.
42
43
44=== Access to environment variables
45
46==== get-environment-variables
47
48<procedure>(get-environment-variables)</procedure>
49
50Returns a association list of the environment variables and their
51current values (see also [[http://srfi.schemers.org/srfi-98/|SRFI-98]]).
52
53==== get-environment-variable
54
55<procedure>(get-environment-variable STRING)</procedure><br>
56
57Returns the value of the environment variable {{STRING}} or
58{{#f}} if that variable is not defined. See also [[http://srfi.schemers.org/srfi-98/|SRFI-98]].
59
60==== set-environment-variable!
61
62<procedure>(set-environment-variable! VARIABLE VALUE)</procedure>
63
64Sets the environment variable named {{VARIABLE}} to
65{{VALUE}}. Both arguments should be strings. If the variable is
66not defined in the environment, a new definition is created.
67
68==== unset-environment-variable!
69
70<procedure>(unset-environment-variable! VARIABLE)</procedure>
71
72Removes the definition of the environment variable {{VARIABLE}} from
73the environment of the current process. If the variable is not defined,
74nothing happens.
75
76
77=== Process filesystem context
78
79==== change-directory
80
81<procedure>(change-directory NAME)</procedure>
82<procedure>(set! (current-directory) NAME)</procedure>
83
84Changes the current working directory to {{NAME}}.
85
86==== change-directory*
87
88<procedure>(change-directory* FD)</procedure>
89<procedure>(set! (current-directory) FD)</procedure>
90
91Changes the current working directory to the one represented by the
92file-descriptor {{FD}}, which should be an exact integer.
93
94'''NOTE''': Windows does not allow {{{open}}} on directories, so while
95technically it is supported, in practice you cannot use this procedure
96on native Windows builds (on cygwin it works because cygwin emulates
97this).
98
99==== current-directory
100
101<procedure>(current-directory)</procedure>
102
103Returns the name of the current working directory.
104
105==== set-root-directory!
106
107<procedure>(set-root-directory! STRING)</procedure>
108
109Sets the root directory for the current process to the path given in
110{{STRING}} (using the {{chroot}} function).  If the current process
111has no root permissions, the operation will fail.
112
113'''NOTE''': On native Windows builds (all except cygwin), this
114procedure is unimplemented and will raise an error.
115
116
117=== Retrieving user & group information
118
119==== current-user-id
120
121<procedure>(current-user-id)</procedure>
122 [setter] (set! (current-user-id) UID)
123
124Get or set the real user-id of the current process. The procedure corresponds to the getuid and setuid C functions.
125
126'''NOTE''': On native Windows builds (all except cygwin), this
127procedure is unimplemented and will raise an error.
128
129==== current-user-id
130
131<procedure>(current-user-name)</procedure>
132
133Get the login name corresponding to the real user-id of the current
134process from the system password database.
135
136On Windows, there's no user-id and no distinction between real and
137effective user, but this procedure ''will'' return the username
138associated with the current process, so it is safe to use.
139
140
141==== current-effective-user-id
142
143<procedure>(current-effective-user-id)</procedure>
144 [setter] (set! (current-effective-user-id) UID)
145
146Get or set the effective user-id of the current process.
147
148'''NOTE''': On native Windows builds (all except cygwin), this
149procedure is unimplemented and will raise an error.
150
151==== current-user-id
152
153<procedure>(current-effective-user-name)</procedure>
154
155Get the login name corresponding to the effective user-id of the
156current process from the system password database.
157
158'''NOTE''': On native Windows builds (all except cygwin), this
159procedure is unimplemented and will raise an error.
160
161==== current-group-id
162
163<procedure>(current-group-id)</procedure>
164 [setter] (set! (current-group-id) GID)
165
166Get or set the real group-id of the current process.
167
168'''NOTE''': On native Windows builds (all except cygwin), this
169procedure is unimplemented and will raise an error.
170
171==== current-effective-group-id
172
173<procedure>(current-effective-group-id)</procedure>
174 [setter] (set! (current-effective-group-id) GID)
175
176Get or set the effective group-id of the current process.
177ID can be found, then {{#f}} is returned.
178
179'''NOTE''': On native Windows builds (all except cygwin), this
180procedure is unimplemented and will raise an error.
181
182=== Process identity
183
184==== current-process-id
185
186<procedure>(current-process-id)</procedure>
187
188Returns the process ID of the current process.
189
190==== parent-process-id
191
192<procedure>(parent-process-id)</procedure>
193
194Returns the process ID of the parent of the current process.
195
196'''NOTE''': On native Windows builds (all except cygwin), this
197procedure is unimplemented and will raise an error.
198
199==== process-group-id
200
201<procedure>(process-group-id PID)</procedure>
202 [setter] (set! (process-group-id PID) PGID)
203
204Get or set the process group ID of the process specified by {{PID}}.
205
206'''NOTE''': On native Windows builds (all except cygwin), this
207procedure is unimplemented and will raise an error.
208
209==== user-information
210
211<procedure>(user-information USER [AS-VECTOR])</procedure>
212
213If {{USER}} specifes a valid username (as a string) or user ID, then
214the user database is consulted and a list of 7 values are returned:
215the user-name, the encrypted password, the user ID, the group ID, a
216user-specific string, the home directory and the default shell. When
217{{AS-VECTOR}} is {{#t}} a vector of 7 elements is returned instead of
218a list. If no user with this name or id then {{#f}} is returned.
219
220Note: on Android systems, the user-specific string is always {{""}},
221since {{pw_gecos}} is not available in the C {{passwd}} struct on that
222platform.
223
224'''NOTE''': On native Windows builds (all except cygwin), this
225procedure is unimplemented and will raise an error.
226
227
228---
229Previous: [[Module (chicken process signal)]]
230
231Next: [[Module (chicken random)]]
Note: See TracBrowser for help on using the repository browser.