Ejemplo n.º 1
0
 BSONObj WaitProgram( const BSONObj& a, void* data ) {
     ProcessId pid = ProcessId::fromNative(singleArg( a ).numberInt());
     int exit_code = -123456; // sentinel value
     wait_for_pid( pid, true, &exit_code );
     registry.deletePid( pid );
     return BSON( string("") << exit_code);
 }
Ejemplo n.º 2
0
BSONObj CheckProgram(const BSONObj& args, void* data) {
    ProcessId pid = ProcessId::fromNative(singleArg(args).numberInt());
    bool isDead = wait_for_pid(pid, false);
    if (isDead)
        registry.deleteProgram(pid);
    return BSON(string("") << (!isDead));
}
Ejemplo n.º 3
0
BSONObj CheckProgram(const BSONObj& args, void* data) {
    ProcessId pid = ProcessId::fromNative(singleArg(args).numberInt());
    int exit_code = -123456;  // sentinel value
    bool isDead = wait_for_pid(pid, false, &exit_code);
    if (!isDead) {
        return BSON("" << BSON("alive" << true));
    }
    return BSON("" << BSON("alive" << false << "exitCode" << exit_code));
}
Ejemplo n.º 4
0
Archivo: vars.c Proyecto: null--/reXp
int main()
{
  printf("MAIN Begins!\n");
  
  printf("Accessing global_var: %d\n", global_var);
  global_var = global_var + 1;
  
  singleArg(750);
  varTest();
   
  return 0;
}
Ejemplo n.º 5
0
BSONObj removeFile(const BSONObj& args, void* data) {
    BSONElement e = singleArg(args);
    bool found = false;

    boost::filesystem::path root(e.valuestrsafe());
    if (boost::filesystem::exists(root)) {
        found = true;
        boost::filesystem::remove_all(root);
    }

    BSONObjBuilder b;
    b.appendBool("removed", found);
    return b.obj();
}
Ejemplo n.º 6
0
        BSONObj cat(const BSONObj& args, void* data) {
            BSONElement e = singleArg(args);
            stringstream ss;
            ifstream f(e.valuestrsafe());
            uassert(CANT_OPEN_FILE, "couldn't open file", f.is_open() );

            streamsize sz = 0;
            while( 1 ) {
                char ch = 0;
                // slow...maybe change one day
                f.get(ch);
                if( ch == 0 ) break;
                ss << ch;
                sz += 1;
                uassert(13301, "cat() : file to big to load as a variable", sz < 1024 * 1024 * 16);
            }
            return BSON( "" << ss.str() );
        }
Ejemplo n.º 7
0
        BSONObj md5sumFile(const BSONObj& args, void* data) {
            BSONElement e = singleArg(args);
            stringstream ss;
            FILE* f = fopen(e.valuestrsafe(), "rb");
            uassert(CANT_OPEN_FILE, "couldn't open file", f );

            md5digest d;
            md5_state_t st;
            md5_init(&st);

            enum {BUFLEN = 4*1024};
            char buffer[BUFLEN];
            int bytes_read;
            while( (bytes_read = fread(buffer, 1, BUFLEN, f)) ) {
                md5_append( &st , (const md5_byte_t*)(buffer) , bytes_read );
            }

            md5_finish(&st, d);
            return BSON( "" << digestToString( d ) );
        }
Ejemplo n.º 8
0
 BSONObj WaitProgram( const BSONObj& a, void* data ) {
     ProcessId pid = ProcessId::fromNative(singleArg( a ).numberInt());
     BSONObj x = BSON( "" << wait_for_pid( pid ) );
     registry.deletePid( pid );
     return x;
 }
Ejemplo n.º 9
0
 BSONObj WaitProgram( const BSONObj& a, void* data ) {
     int pid = singleArg( a ).numberInt();
     BSONObj x = BSON( "" << wait_for_pid( pid ) );
     registry.deletePid( pid );
     return x;
 }