I\'m currently working on an online C/C++/assembly compiler, and I stumbled upon a nice piece of software called libsandbox. This enables me to run the online written code, comp
The sandbox is for linux only. You must actually create the sandbox first by using the library functions and then tell the sandbox to run your program.
This python sample shows how to do it from python. The line "#targeted program" shows you where you will specify the name of your actual application.
def main(args):
# sandbox configuration
cookbook = {
'args': args[1:], # targeted program
'stdin': sys.stdin, # input to targeted program
'stdout': sys.stdout, # output from targeted program
'stderr': sys.stderr, # error from targeted program
'quota': dict(wallclock = 30000,# 30 sec
cpu = 2000, # 2 sec
memory = 8388608, # 8 MB
disk = 1048576)} # 1 MB
# create a sandbox instance and execute till end
msb = MiniSandbox(**cookbook)
msb.run()
# verbose statistics
sys.stderr.write("result: %(result)s\ncpu: %(cpu)dms\nmem: %(mem)dkB\n" % \
msb.probe())
return os.EX_OK
I would recommend going to the libsandbox download page and getting the full sample2.py file there and then just running the sandbox using the python script. This will be easier than making a C++ or C program to do it for you.
So...
Make your C or C++ program. DO NOT LINK IT TO LIBSANDBOX.
Make sure you have python installed.
Run the sample python script from the libsandbox page.
The python script will load the libsandbox for you. Then it will run the program you have built inside the sandbox.
Simple.
The short and general answer is: to use libanything, you write a program that utilizes that library - you #include <anything.h>
into the source and link with -lanything
switch. You're not supposed to find any executable files, unless it's a test suite or an example program for the library.
I wasn't able to find 'libsandbox' for some reason, so my reply might be grossly inaccurate.
Totally agree with the answer from @user1401452. Some more tips about libsandbox,
DISCLAIMER: I am the author of libsandbox