//this function does what's needed for each built-in command. Note: these commands cannot be //run in the background. Returns 1 if a built-in command is detected, 0 if not int builtInCmd(char *argList[], struct hist *histList, int count) { int cdCheck; int isBuiltIn = 1; //builtin exit command if (strcmp(argList[0], "exit") == 0) { printf("Exiting shell...\n\n"); exit(0); //builtin cd (change directory) command, implemented with chdir() system call } else if (strcmp(argList[0], "cd") == 0) { if ((cdCheck = chdir(argList[1]) == -1)) { printf("chdir() failure... now exiting shell"); _exit(EXIT_FAILURE); } //builtin command to display history } else if (strcmp(argList[0], "history") == 0) { printHistory(&histList[0], count); //builtin command to display currently running jobs } else if (strcmp(argList[0], "jobs") == 0) { updateJobs(); printJobs(); //builtin command to bring a background job to the foreground } else if (strcmp(argList[0], "fg") == 0) { if (argList[1] == NULL) printf("Invalid command: must give a Process ID number with the fg command.\n"); if (bringToForeground(argList) == 0) printf("The process with that PID is not currently running.\n"); } else { isBuiltIn = 0; } return isBuiltIn; }
void KMJobViewer::refresh(bool reload) { m_jobs.clear(); QPtrListIterator<KMJob> it(m_manager->jobList(reload)); bool all = (m_prname == i18n("All Printers")), active = (m_type == KMJobManager::ActiveJobs); for (; it.current(); ++it) if ((all || it.current()->printer() == m_prname) && ((it.current()->state() >= KMJob::Cancelled && !active) || (it.current()->state() < KMJob::Cancelled && active)) && (m_username.isEmpty() || m_username == it.current()->owner())) m_jobs.append(it.current()); updateJobs(); // update the caption and icon (doesn't do anything if it has a parent widget) updateCaption(); updateStatusBar(); // do it last as this signal can cause this view to be destroyed. No // code can be executed safely after that emit jobsShown(this, (m_jobs.count() != 0)); }