Skip to content

Modify the handling of exit to throw the correct code #1316

Closed
@Thirumalai-Shaktivel

Description

@Thirumalai-Shaktivel

I recently came across something like this:

def test():
	quit(10)

test()
$ lpython a.py
err = 2560
STOP
$ echo $?
1

So, I thought to replace this with the following change:

                if (err != 0) {
                    if (0 < err && err < 256) {
                        return err;
                    } else if (err % 256 == 0) {
                    	return err / 256;
                    } else {
                        return 1;
                    }
                }

@certik

Originally posted by @Thirumalai-Shaktivel in #1302 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions