void move_to_background(pid_t pgid, int state, char *command, int len) { int jid = find_job(pgid); if (jid < 0) add_job(pgid, state, command, len); else update_job(pgid, state); }
void let_it_fly() { if (daemon(1, 1) == -1) ERR_EXIT("daemon error"); update_job(); int fork_status; for (auto resource:resources) { fork_status = fork(); if (fork_status == -1) { ERR_EXIT("fork error"); } else if (fork_status > 0) { resource_pid[resource.first] = fork_status; } else { monitor_handle(resource.first); } } //TODO main process }
int main (int argc, char *argv[]) { // if(daemon_init() == -1){ // printf("can not fork self"); // exit(0); // } //===================== // char IP[16]; // uint32_t PORT; // // get_IP_PORT(IP, &PORT, IP_CONFIG_FILE); // // running(IP, PORT); //============================ uint32_t jobid = 0; allocate_test(&jobid); sleep(5); if(jobid > 0) update_job(jobid); return 0; }
/* * Update a Pool Record in the database. * It is always updated from the Resource record. * * update pool=<pool-name> * updates pool from Pool resource * update media pool=<pool-name> volume=<volume-name> * changes pool info for volume * update slots [scan=...] * updates autochanger slots * update stats [days=...] * updates long term statistics */ int update_cmd(UAContext *ua, const char *cmd) { static const char *kw[] = { NT_("media"), /* 0 */ NT_("volume"), /* 1 */ NT_("pool"), /* 2 */ NT_("slots"), /* 3 */ NT_("slot"), /* 4 */ NT_("jobid"), /* 5 */ NT_("stats"), /* 6 */ NULL}; if (!open_client_db(ua)) { return 1; } switch (find_arg_keyword(ua, kw)) { case 0: case 1: update_volume(ua); return 1; case 2: update_pool(ua); return 1; case 3: case 4: update_slots(ua); return 1; case 5: update_job(ua); return 1; case 6: update_stats(ua); return 1; default: break; } start_prompt(ua, _("Update choice:\n")); add_prompt(ua, _("Volume parameters")); add_prompt(ua, _("Pool from resource")); add_prompt(ua, _("Slots from autochanger")); add_prompt(ua, _("Long term statistics")); switch (do_prompt(ua, _("item"), _("Choose catalog item to update"), NULL, 0)) { case 0: update_volume(ua); break; case 1: update_pool(ua); break; case 2: update_slots(ua); break; case 3: update_stats(ua); break; default: break; } return 1; }