Add preserve_process_environment

This commit is contained in:
Emery Hemingway 2023-05-18 17:48:50 +01:00
parent 2a1a3fe200
commit e898bc62db
3 changed files with 27 additions and 1 deletions

View File

@ -13,3 +13,8 @@ Do not send messages immediately to the dataspace passed `json_socket_translator
## msg
A utility that sends a message to $SYNDICATE_SOCK in the form `<ARGV…>`.
## preserve_process_environment
This utility serializes it's process environment to Preserves and prints it to stdout.
It can be used to feed the environment variables of a nested child of the Syndicate server back to the server. For example, to retreive the environmental variables that a desktop manager passed on to its children.

View File

@ -0,0 +1,21 @@
# SPDX-FileCopyrightText: ☭ Emery Hemingway
# SPDX-License-Identifier: Unlicense
import std/[tables, os]
import preserves
type ProcessInfo {.preservesDictionary.} = object
program: string
argv: seq[string]
env: Table[string, string]
dir: string
proc main =
var info: ProcessInfo
info.program = getAppFilename()
info.argv = commandLineParams()
for key, val in envPairs(): info.env[key] = val
info.dir = getCurrentDir()
writeLine(stdout, info.toPreserve)
main()

View File

@ -5,7 +5,7 @@ author = "Emery Hemingway"
description = "Utilites for Syndicated Actors and Synit"
license = "unlicense"
srcDir = "src"
bin = @["json_socket_translator", "json_translator", "msg"]
bin = @["json_socket_translator", "json_translator", "msg", "preserve_process_environment"]
# Dependencies