nomann@rimfaxe.diku.dk (Ole Nomann Thomsen) (10/05/90)
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.