visit-dav / visit

VisIt - Visualization and Data Analysis for Mesh-based Scientific Data
https://visit.llnl.gov
BSD 3-Clause "New" or "Revised" License
442 stars 116 forks source link

VisIt script always exits with non-zero return value #19671

Closed iljah closed 2 months ago

iljah commented 4 months ago

Describe the bug

When programs exit without error their return value is 0 on fedora/linux/posix/unix? systems.

When VisIt script consisting of only #! /usr/bin/env -S visit -nowin -cli -s exits its return value is 250, which breaks e.g. command chaining with &&, etc. This script also exits with value 250:

#! /usr/bin/env -S visit -nowin -cli -s
exit()

To Reproduce

With above script(s) (note ; instead of &&):

$ ./test2.py; echo $?
Running: cli3.0.2 -nowin -s ./test2.py
Running: viewer3.0.2 -nowin -noint -host 127.0.0.1 -port 5600
250

Expected behavior

When no errors happen, visit should exit with return value 0 so that subsequent command line commands are also executed (note && instead of ;):

$ ./test2.py && echo $?
Running: cli3.0.2 -nowin -s ./test2.py
Running: viewer3.0.2 -nowin -noint -host 127.0.0.1 -port 5600
0

Desktop

Also tested with 3.4.1 from https://github.com/visit-dav/visit/releases/download/v3.4.1/visit3_4_1.linux-x86_64-fedora31.tar.gz

iljah commented 4 months ago

Above scripts might require this to work: https://github.com/visit-dav/visit/pull/19346

cyrush commented 3 months ago

@iljah

It looks like I am able to return a specific code from the CLI, does the following work for you?

$ visit -nowin -cli

import sys sys.exit(0) $ echo $? 0 $ visit -nowin -cli sys.exit(100) $ echo $? 100

iljah commented 2 months ago

Not sure if exit() and sys.exit() are different things but neither works for me:

$ visit -nowin -cli
Running: cli3.4.1 -nowin
Running: viewer3.4.1 -nowin -noint -host 127.0.0.1 -port 5600
>>> exit(0)
$ echo $?
250
$ visit -nowin -cli
Running: cli3.4.1 -nowin
Running: viewer3.4.1 -nowin -noint -host 127.0.0.1 -port 5600
>>> from sys import exit; exit(0)
$ echo $?
250
JustinPrivitera commented 2 months ago

Strange. I see the following:

$ visit -nowin -cli
Running: cli3.4.1 -nowin
Running: viewer3.4.1 -nowin -noint -host 127.0.0.1 -port 5601
>>> exit(0)
$ echo $?
0
$ visit -nowin -cli
Running: cli3.4.1 -nowin
Running: viewer3.4.1 -nowin -noint -host 127.0.0.1 -port 5601
>>> import sys
>>> sys.exit(0)
$ echo $?
0

Do any @visit-dav/visit-developers have access to a fedora 40 system to attempt to reproduce?

iljah commented 2 months ago

os._exit(0) seems to work:

$ visit -nowin -cli
Running: cli3.4.1 -nowin
Running: viewer3.4.1 -nowin -noint -host 127.0.0.1 -port 5600
>>> import os; os._exit(0)
$ echo $?
0
cyrush commented 2 months ago

@iljah I am glad you found a working solution. I am not sure why the return codes don't propagate from the other calls on your system.

JustinPrivitera commented 2 months ago

Can we close this ticket then?

iljah commented 2 months ago

Sure, thanks.