Fork–exec is a used technique in Unix whereby an executing process spawns a new program. Fork is the name of the system call that the parent process uses to "divide" itself into two identical processes. After calling fork, the created child process is an exact copy of the parent except for the return value of the fork call; this includes open files, register state, all memory allocations, which includes the program's executable code. In some cases the two continue to run the same binary, but one switches to running another binary executable using the exec system call; when a process forks, a complete copy of the executing program is made into the new process. This new process has a new process identifier; the fork function returns the child's PID to the parent, while it returns 0 to the child, in order to allow the two identical processes to distinguish one another. The parent process can either wait for the child process to complete; the child, after discovering that it is the child, replaces itself with another program, so that the code and address space of the original program are lost.
If the parent chooses to wait for the child to die the parent will receive the exit code of the program that the child executed. To prevent the child becoming a zombie the parent should call wait on its children, either periodically or upon receiving the SIGCHLD signal, which indicates a child process has terminated. One can asynchronously wait on their children to finish, by using a signal handler for SIGCHLD, if they need to ensure everything is cleaned up. Here's an example of a signal handler that catches any incoming SIGCHLD signals and handles multiple concurrent signals received; when the child process calls exec, all data in the original program is lost, it is replaced with a running copy of the new program. This is known as overlaying. Although all data are replaced, the file descriptors that were open in the parent are closed only if the program has explicitly marked them close-on-exec; this allows for the common practice of the parent creating a pipe prior to calling fork and using it to communicate with the executed program.
Microsoft Windows does not support the fork-exec model, as it does not have a system call analogous to fork. The spawn family of functions declared in process.h can replace it in cases where the call to fork is followed directly by exec. When a fork syscall is made on WSL, lxss.sys does some of the initial work to prepare for copying the process. It calls internal NT APIs to create the process with the correct semantics and create a thread in the process with an identical register context, it does some additional work to complete copying the process and resumes the new process so it can begin executing. "File descriptors across fork/exec", Operating Systems, Franco Callari, Electrical Engineering Department, McGill University "fork and exec", Tim Love, University of Cambridge Engineering Department Advanced Programming in the UNIX Environment, W. Richard Stevens, Addison-Wesley ISBN 0-201-56317-7 Unix Power Tools, Jerry Peek, Tim O'Reilly, Mike Loukides, O'Reilly, ISBN 1-56592-260-3
Metagaming is a term used in role-playing games, which describes a player's use of real-life knowledge concerning the state of the game to determine their character's actions, when said character has no relevant knowledge or awareness under the circumstances. This can refer to plot information in the game such as secrets or events occurring away from the character, as well as facets of the game's mechanics such as abstract statistics or the precise limits of abilities. Metagaming is an example of "breaking character", as the character is making decisions based on information they couldn't know and thus would not make in reality. Metagaming is considered unsporting or cheating in a competitive gaming context, is poorly received as it subverts the emphasis of accurate character depiction based on in-game experiences and back-story that defines role-playing games. Outside of role-playing, metagaming refers to players using knowledge or understanding of external factors to gain an advantage in competition.
More broadly, metagaming can refer any or all aspects of play that occur outside of a given game's fictional setting. This most prominently includes any discussion among players and/or the game's master about the game's events and contents. Traditionally, metagaming is frowned upon in role-playing communities, as it upsets the suspension of disbelief and affects game balance. However, some narrativist indie role-playing games deliberately support metagaming in "Director stance" and encourage shared storytelling among players, it can be contrasted with live action roleplaying games with a more cinematic style, where the use of metagame references to specific books and films, either before the game or during play, prompts the players as to the atmosphere the organisers are aiming to create. Gathering knowledge: Any action, based upon the real-life knowledge that one is playing a game. Gaining knowledge from Out-Of Character. Using in-world knowledge from a played or dead character. In split-screen games, using another player's viewpoint to gather information that one's own character doesn't know and could not access.
Bending the rules: Adjusting a character's actions based on foreknowledge of the long-term intentions of the gamemaster. Basing a character's decision on knowledge of the game's mechanics to gain an advantage, when the resulting action goes against that character's personality, history or motives; as a form of powergaming during character creation, when a player takes flaws or liabilities that they know the gamemaster is unlikely to exploit, thereby acquiring extra creation options without paying a corresponding penalty. Altering behaviors: Using certain types of attack or defense based on the strengths and weaknesses of an opponent of which the player's character has no knowledge. Acting on any knowledge that the character doesn't know and could not learn - for example, applying real-life chemistry to create gunpowder in a pre-firearms setting, without said character having any foreknowledge or interest in chemistry or any precedence for its development. Adjusting a character's behavior towards other player characters based on real-life relationships with other players.
This extends to and includes attempts to engender friendships or relationships, manipulate those of others, via favouritism in-game. Deciding on a character's course of action based on how the game's abstract mechanics will affect the outcome. Assuming that something that appears to be wrong or unlikely in the game world is a mistake of the game's master rather than something that could be investigated. Assuming that if an item is mentioned by the gamemaster during the initial description of an area, it must have some relevance to the storyline, searching or examining it.. Fourth wall Min-maxing Munchkin Powergaming Twinking "An Australian Convention Roleplaying Glossary". Archived from the original on April 28, 2006. "Role-playing games glossary". Archived from the original on June 14, 2006; the Last Dark Art: Exploring the Gaming Aesthetic – RPGnet article on metagaming