File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1649,7 +1649,7 @@ int main(int argc, char *argv[])
16491649 err = system ((" js " + outfile +" .js" ).c_str ());
16501650 } else {
16511651 if (compiler_options.platform == LFortran::Platform::Windows) {
1652- err = system (outfile.c_str ());
1652+ return system (outfile.c_str ());
16531653 } else {
16541654 err = system ((" ./" + outfile).c_str ());
16551655 }
@@ -1658,7 +1658,9 @@ int main(int argc, char *argv[])
16581658 if (0 < err && err < 256 ) {
16591659 return err;
16601660 } else {
1661- return 1 ;
1661+ // https://stackoverflow.com/a/27117435/15913193
1662+ // https://linux.die.net/man/3/system
1663+ return LFortran::get_exit_status (err);
16621664 }
16631665 }
16641666 }
Original file line number Diff line number Diff line change @@ -103,4 +103,8 @@ bool path_exists(std::string path) {
103103 }
104104}
105105
106+ int32_t get_exit_status (int32_t err) {
107+ return (((err) >> 8 ) & 0x000000ff );
108+ }
109+
106110}
Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ std::string get_runtime_library_header_dir();
1212bool is_directory (std::string path);
1313bool path_exists (std::string path);
1414
15+ int32_t get_exit_status (int32_t err);
16+
1517} // LFortran
1618
1719#endif // LFORTRAN_UTILS_H
You can’t perform that action at this time.
0 commit comments