diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-03-07 12:36:54 -0500 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-03-07 12:36:54 -0500 |
commit | d9960fc90cb19bfd75cd37133775862ad945834b (patch) | |
tree | 8a108e8cc3bda8c0c0e27e9b0f5b68a8d49aebc3 /src | |
parent | fec3ee14f4ecf91441f9198a5e78b2d882650119 (diff) | |
download | stasis-d9960fc90cb19bfd75cd37133775862ad945834b.tar.gz |
Add CLI option to disable line buffering
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -40,6 +40,7 @@ static struct option long_options[] = { {"config", optional_argument, 0, 'c'}, {"python", optional_argument, 0, 'p'}, {"verbose", no_argument, 0, 'v'}, + {"unbuffered", no_argument, 0, 'U'}, {"update-base", optional_argument, 0, OPT_ALWAYS_UPDATE_BASE}, {0, 0, 0, 0}, }; @@ -51,6 +52,7 @@ const char *long_options_help[] = { "Read configuration file", "Override version of Python in configuration", "Increase output verbosity", + "Disable line buffering", "Update conda installation prior to OMC environment creation", NULL, }; @@ -145,7 +147,7 @@ int main(int argc, char *argv[], char *arge[]) { int c; while (1) { int option_index; - c = getopt_long(argc, argv, "hVCc:p:v", long_options, &option_index); + c = getopt_long(argc, argv, "hVCc:p:vU", long_options, &option_index); if (c == -1) { break; } @@ -168,6 +170,13 @@ int main(int argc, char *argv[], char *arge[]) { case OPT_ALWAYS_UPDATE_BASE: arg_always_update_base_environment = 1; break; + case 'U': + setenv("PYTHONUNBUFFERED", "1", 1); + fflush(stdout); + fflush(stderr); + setvbuf(stdout, NULL, _IONBF, 0); + setvbuf(stderr, NULL, _IONBF, 0); + break; case 'v': globals.verbose = 1; break; |