https://github.com/ultmaster/runexe
A *NIX only version for Codeforces Polygon runexe
https://github.com/ultmaster/runexe
sandbox
Last synced: about 1 year ago
JSON representation
A *NIX only version for Codeforces Polygon runexe
- Host: GitHub
- URL: https://github.com/ultmaster/runexe
- Owner: ultmaster
- Created: 2018-12-25T04:20:16.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-07-18T21:53:37.000Z (almost 4 years ago)
- Last Synced: 2025-01-23T05:45:27.744Z (over 1 year ago)
- Topics: sandbox
- Language: C++
- Homepage:
- Size: 1.83 MB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# runexe
Modified from the `runexe` written by the famous Mirzayanov from Saratov State U.
The motivation is to write a cross-platform runner for Hypercube, but as far as
I'm concerned, there isn't a package for that, until I noticed runexe.
They have provided an exe in the polygon package; also a legendary version (old and
unmaintained) of runexe is on the Github. So I want to modify this, so that the API
will eventually match the Windows version, at least for those features I'm going to use.
Here is what I have done:
* Interaction
* Wrap the old `invocationResult` in `invocationResults`.
* `SUCCESS` to `SUCCEEDED`.
* A total refactorization of prettification of the project code.
* Use `rlimit` to limit the resource.
* Add `G` as a possible unit for memory.
* Remove other features that I'm not gonna use and also are confusing me, such as,
login switch, environment setup, idleness check (on by default) and etc.
No security features (restrictions on system calls) are added, as it was not intended
to build a sandbox for some online judge. However, this could be a good start, if you
are also seeking some solution in untrusted-code-running-with-restrictions.
## Command line help
```
RunExe for *NIX, Version 1.0
This program runs other program(s) for given period of time with specified
restrictions.
Command line format:
runexe [] [] program []
Global options:
-help - show help
-xml - print result in xml format (otherwise, use human-readable)
-interactor=" interactor "
INTERACTOR MODE
Launch another process and cross-connect its stdin&stdout with the main
program. Inside this flag, you can specify any process-controlling flags:
interactor can have its own limits, credentials, environment, directory.
In interactor mode, however, -i and -o have no effects on both main
program and interactor.
-ri= - in interactor mode, record program input to file .
-ro= - in interactor mode, record program output to file .
Process properties:
-t - time limit. Terminate after seconds, you can use
suffix ms to switch to milliseconds. Suffix "s" (seconds)
can be omitted.
-m - memory limit. Terminate if anonymous virtual memory of the
process exceeds bytes. Use suffixes K, M, G to
specify kilo, mega, gigabytes.
-d - current directory for the process.
-i - redirect standard input to .
-o - redirect standard output to .
-e - redirect standard error to .
```
## Reference
This part is taken from the Windows version and it's only for my reference.
```
runexe 2.0 version c5a5c20c3bc925a2bbb96cab39d7c21c871d2960 build 138
This program runs other program(s) for given period of time with specified
restrictions.
Command line format:
runexe [] [] program []
Global options:
-help - show help
-xml - print result in xml format (otherwise, use human-readable)
-show-kernel-mode-time - include kernel-mode time in human-readable format
(always included in xml)
-x - return process exit code (not implemented)
-logfile= - for runexe developers only
-interactor=" interactor "
INTERACTOR MODE
Launch another process and cross-connect its stdin&stdout with the main
program. Inside this flag, you can specify any process-controlling flags:
interactor can have its own limits, credentials, environment, directory.
In interactor mode, however, -i and -o have no effects on both main
program and interactor.
-ri= - in interactor mode, record program input to file .
-ro= - in interactor mode, record program output to file .
Process properties:
-t - time limit. Terminate after seconds, you can use
suffix ms to switch to milliseconds. Suffix "s" (seconds)
can be omitted.
-m - memory limit. Terminate if anonymous virtual memory of the
process exceeds bytes. Use suffixes K, M, G to
specify kilo, mega, gigabytes.
-D k=v - environment. If any is specified, existing environment is
cleared.
-d - current directory for the process.
-l - login name. Create process under user.
-p - password for user specified in -l. On linux, ignored (but
must be present).
-j - inject DLL into process.
-i - redirect standard input to .
-o - redirect standard output to .
-e - redirect standard error to .
-z - run process in trusted mode.
-no-idleness-check - switch off idleness checking.
```
And here is an example of verbose output and xml output.
```
Program successfully terminated
exit code: 0
time consumed: 0.02 sec
time passed: 0.17 sec
peak memory: 6963200 bytes
Interactor successfully terminated
exit code: 0
time consumed: 0.00 sec
time passed: 0.70 sec
peak memory: 27480064 bytes
```
```
SUCCEEDED
0
15
62
176
6909952
SUCCEEDED
0
0
31
695
27402240
```