Source Code, Programs, and Running Processes
A saved program can produce several independent executions, each with its own input, state, output, and lifetime.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 2 min
In this article4 chapters
Identify the thing that changed
Source code is a description stored in one or more files. A running process is an instance managed by the operating system. It has resources such as memory and open files. A language runtime may interpret, translate, or load parts of the program on the way to executing it. Script and module entry points specify which initialization happens first.
Two runs from the same file
Consider a script that reads a ticket count, adds one, and prints the result. Running it twice with inputs 7 and 20 can produce 8 and 21 independently. The in-memory count from the first run vanishes with that process. If both runs write the same filename, the file provides shared state outside either run. When explaining a side effect, name the resource it changes.[1][2]
Give two launches different environments
A saved report script may contain no literal output location. At startup, each launch can receive its own working directory, arguments, and environment. A relative output path resolves according to that process's working directory. If one launch starts from a training folder and another starts from a project folder, the same source can read different input files while following the same instructions.
Make the distinction concrete by running a harmless report twice on two different supplied files. One file can contain two rows and the other three. Each process can begin with count zero, read its own file, and emit its own count. There is no need for the first invocation to remember anything for the second to work. If both write one shared report filename, however, you have added a resource outside either process. The final file then depends on when and how each writer publishes its result.
Locate changes that survive a run
When a command behaves differently the second time, list everything it can read that survives its first exit. A saved output, an updated configuration, or a database change could affect the new process. Distinguish these from a counter stored in the first process's memory. Logs can also help identify which run handled an action. Record separate launch times and input identifiers when comparing outcomes.
See process identity and lifetime for how an operating system distinguishes two runs from one executable. To test a command that is meant to create an independent result, use two temporary output locations and verify both files separately. Then try the deliberately shared location under the feature's promised overwrite or append rule.