9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: beto@plan9.cs.su.oz.au beto@plan9.cs.su.oz.au
Subject: Panel + forks + postnote
Date: Fri, 13 Oct 1995 15:29:23 -0400	[thread overview]
Message-ID: <19951013192923.p310uFZ5Wv6r5NeNLXsasWYGcHvN0SJTna11eb1iiLI@z> (raw)

Hi, 

I'm writing a program which uses the Panel library, 
starts new processes based on mouse actions and
after a while kills those processes, but the interface
should not died. Is this possible? Has any one tried?
Mothra uses it, put only kills subprocesses in fatal
conditions, which do not require the Panel to keep 
working.

I'm having problems after killing processes with
the panel library. It looks like there is some kind of
sincronization program, I'm not quite sure what's going on.
The error is 
	bitblt: bad slave 32 on event pipe: fd out of
	range or not open

Here is an small program with I hope will
reproduce the problem. 

Any help would be appreciated.
thanks
beto


#include <u.h>
#include <libc.h>
#include <libg.h>
#include <panel.h>
Panel *root;

void playnetwork(void);
void killall(void);

void restart(Panel *p, int buttons){
	USED(p, buttons);
	killall();
	playnetwork();
}
/*
  * To see the problem just press
  * retstart
  */
void main(void){
	rfork(RFNOTEG|RFNAMEG);
	binit(0, 0, 0);
	einit(Emouse);
	plinit(screen.ldepth);

	root=plframe(0, 0);
	pllabel(root, 0, "Playing.....");
	plbutton(root, 0, "restart", restart);

	ereshaped(screen.r);
	playnetwork();
	for(;;) plmouse(root, emouse());
}

void ereshaped(Rectangle r){
	screen.r=r;
	plpack(root, r);
	bitblt(&screen, r.min, &screen, r, Zero);
	pldraw(root, &screen);
}


/* from mothra.c */
void filter(char *cmd, int fd, int teefd){
	char cmdbuf[512];
	if(teefd!=-1) sprint(cmdbuf, "tee -a /fd/%d | %s", teefd, cmd);
	else strcpy(cmdbuf, cmd);
	bflush();
	switch(rfork(RFFDG|RFPROC|RFNOWAIT)){
	case -1:
		break;
	case 0:
		/*close(0);
		bclose();
		dup(fd, 0);
		close(fd);/**/
		execl("/bin/rc", "rc", "-c", cmdbuf, 0);
		_exits(0); 
	default:
		break;
	}
	close(teefd);
	close(fd);
}
void
playnetwork(void)
{
	filter("sleep 1000", 0,-1);
}
void 
killall(void)
{
	postnote(PNGROUP, getpid(), "kill\n");
}






             reply	other threads:[~1995-10-13 19:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-10-13 19:29 beto [this message]
  -- strict thread matches above, loose matches on Subject: below --
1995-10-16 22:31 beto
1995-10-13 13:27 td

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19951013192923.p310uFZ5Wv6r5NeNLXsasWYGcHvN0SJTna11eb1iiLI@z \
    --to=beto@plan9.cs.su.oz.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).