🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.unix.programmer
1 messages
1 total messages Started by Ole Nomann Thomsen Fri, 05 Oct 1990 16:48
Doing job-control on you own ?
#987
Author: Ole Nomann Thomsen
Date: Fri, 05 Oct 1990 16:48
56 lines
2013 bytes
Hello All.

I am trying to write a small shell-like program, that will enable me
to simulate a limited form of job-control on a system that hasn't got
it. (SCO Xenix rel. 2.3.2).

What I have in mind is this:

$ co-start prog1 prog2

Now, prog1 is active, until you generate some signal, at which
point prog1 is suspended, and prog2 starts up (and so on). To simplify
things, I will avoid detaching the suspended process from the terminal
and stuff like that.

My idea was something like this:

main()
{
	signal(SOMESIGNAL, switch);
	/* SOMESIGNAL should be something the keyboard could generate */

	if (fork() == 0) exec ("Prog1");
	if (fork() == 0) exec ("Prog2");

	/* do something else */
}

switch()
{
	static int flag;

	if (flag == MYTURN) {
		flag = NOTMYTURN;
		resume; /* probably some longjump */
	} else {
		flag = MYTURN;
		sleep (INFINITE);
	}
}

But then I realised: "Hey, the signal(SOMESIGNAL, switch) will never
survive the exec!", and I got stuck.

Isn't there some way of doing this, even when you <som'thing>IX
doesn't support job control? Or have I just asked for the impossible?

I would really appriciate help, ranging from: "You misused fork()" to:
"Ah, what you need is probably this: <CODE> Have fun.", or perhaps even:
"This is impossible because of <REASON>, you poor ignorant soul.".

Standard nettiquette applies: Please E-mail, and I'll post a summary.

- Ole. (nomann@diku.dk).

"Information is not knowledge" - Frank Zappa. 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads