YASH 0.1
CLI written in C
Loading...
Searching...
No Matches
jobs.c File Reference

Job control functions for the YASH shell. More...

#include "../include/jobs.h"
#include "../include/yash.h"
#include <stdio.h>
#include <string.h>

Functions

void jobs_init (void)
 Initialize the job table.
 
int jobs_add (pid_t pgid, const char *cmdline, int is_background)
 Add a job to the job table.
 
void jobs_mark (pid_t pgid, JobStatus status)
 Mark a job as running or stopped.
 
void jobs_print ()
 Print all jobs.
 
int jobs_pick_most_recent_for_fg (void)
 Pick the most recent job for foreground.
 
int jobs_pick_most_recent_stopped_for_bg (void)
 Pick the most recent stopped job for background.
 
pid_t jobs_get_pgid (int job_id)
 Get the pgid of a job.
 
void jobs_reap_done_and_print (void)
 Reap done jobs and print them.
 
void jobs_print_one (int job_id)
 Print a single job.
 
const char * jobs_get_cmdline (int job_id)
 Get the cmdline of a job.
 
void jobs_set_background (pid_t pgid, int is_bg)
 Set the background of a job.
 

Detailed Description

Job control functions for the YASH shell.

Author
Nathan Lemma
Date
09-16-2025

This file contains the job control functions for the YASH shell.

Function Documentation

◆ jobs_add()

int jobs_add ( pid_t pgid,
const char * cmdline,
int is_background )

Add a job to the job table.

Parameters
pgid
cmdline
is_background
Returns
int

◆ jobs_get_cmdline()

const char * jobs_get_cmdline ( int job_id)

Get the cmdline of a job.

Parameters
job_id
Returns
const char*

◆ jobs_get_pgid()

pid_t jobs_get_pgid ( int job_id)

Get the pgid of a job.

Parameters
job_id
Returns
pid_t

◆ jobs_mark()

void jobs_mark ( pid_t pgid,
JobStatus status )

Mark a job as running or stopped.

Parameters
pgid
status

◆ jobs_pick_most_recent_for_fg()

int jobs_pick_most_recent_for_fg ( void )

Pick the most recent job for foreground.

Returns
int

◆ jobs_pick_most_recent_stopped_for_bg()

int jobs_pick_most_recent_stopped_for_bg ( void )

Pick the most recent stopped job for background.

Returns
int

◆ jobs_print_one()

void jobs_print_one ( int job_id)

Print a single job.

Parameters
job_id

◆ jobs_set_background()

void jobs_set_background ( pid_t pgid,
int is_bg )

Set the background of a job.

Parameters
pgid
is_bg