Boost License 1.0. Authors:
Walter Bright, Andrei Alexandrescu Source:
- int system(string command);
- Execute command in a command shell.
If command is null, returns nonzero if the command interpreter is found, and zero otherwise. If command is not null, returns -1 on error, or the exit status of command (which may in turn signal an error in command's execution). Note:
On Unix systems, the homonym C function (which is accessible to D programs as std.c.system) returns a code in the same format as waitpid, waitpid, meaning that C programs must use the WEXITSTATUS macro to extract the actual exit code from the system call. D's system automatically extracts the exit status.
- int execv(in string pathname, in string argv);
int execve(in string pathname, in string argv, in string envp);
int execvp(in string pathname, in string argv);
int execvpe(in string pathname, in string argv, in string envp);
- Execute program specified by pathname, passing it the arguments (argv) and the environment (envp), returning the exit status. The 'p' versions of exec search the PATH environment variable setting for the program.
- alias getpid;
- Returns the process ID of the calling process, which is guaranteed to be
unique on the system. This call is always successful.
writefln("Current process id: %s", getpid());
- string getenv(in char name);
- Gets the value of environment variable name as a string. Calls std.c.stdlib.getenv internally.
- void setenv(in char name, in char value, bool overwrite);
- Sets the value of environment variable name to value. If the value was written, or the variable was already present and overwrite is false, returns normally. Otherwise, it throws an exception. Calls std.c.stdlib.setenv internally.
- void unsetenv(in char name);
- Removes variable name from the environment. Calls std.c.stdlib.unsetenv internally.
- alias environment;
- Manipulates environment variables using an associative-array-like
// Return variable, or throw an exception if it doesn't exist. auto path = environment["PATH"]; // Add/replace variable. environment["foo"] = "bar"; // Remove variable. environment.remove("foo"); // Return variable, or null if it doesn't exist. auto foo = environment.get("foo"); // Return variable, or a default value if it doesn't exist. auto foo = environment.get("foo", "default foo value"); // Return an associative array of type string[string] containing // all the environment variables. auto aa = environment.toAA();