9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] a curious process
@ 1998-08-16 12:34 forsyth
  0 siblings, 0 replies; 2+ messages in thread
From: forsyth @ 1998-08-16 12:34 UTC (permalink / raw)


the process is still attached to the original name space
including the file service connection
authenticated by you, not none.  try calling newns
to clear the association.




^ permalink raw reply	[flat|nested] 2+ messages in thread

* [9fans] a curious process
@ 1998-08-16  6:02 arisawa
  0 siblings, 0 replies; 2+ messages in thread
From: arisawa @ 1998-08-16  6:02 UTC (permalink / raw)


Hello 9fans!

I observed a curious process:
The process of 'none' creates a file of 'arisawa'.
Does plan9 admit such a process?

The program is listed bellow.

I have felt inconvenience to kill the processes of none
because my system forbids login by none.
So I wrote a program that is executed as none instead of me.

Try something:
[1] done ps
[2] done  'echo kill > /proc/524/note'
	# where 524 is the process id to kill
	# you can observe that done can kill processes of none
[3] done touch x
	# done cannot create files of none, but creates files of you!

--------------- done.c ---------------
/*
	done: do as none
	usage: done command
	example:
		done broke
		done 'echo kill > /proc/524/ctl'

	I felt inconvenient to kill processes of none, so I wrote.

	1998/08/14
	Kenji Arisawa (Kenar)
	E-mail: arisawa@ar.aichi-u.ac.jp
*/

#include <u.h>
#include <libc.h>

void
usage(void)
{       print("usage: done command\n");
        exits("usage");
}

void
main(int argc, char **argv)
{	int f,i,n,r;
	char buf[256], *s;
	Waitmsg w;

	/* ---------------------------------
	*	we combine argments to a single string.
	*	"arg1 arg2 arg3 ... "
	*/
	*buf = 0;
	r = 256 - 2;
	s = buf;
	for(n = 1; n < argc; n++){
		i = strlen(argv[n]);
		if(i > r) { /* error. so we exit */
			fprint(2,"command line to long\n");
			exits("argments");
		}
		strcpy(s, argv[n]);
		s += i;
		strcpy(s, " ");
		s++;
		r -= i + 1;
	}
	s--;
	*s = 0;
		
	argv[0] = "rc";
	argv[1] = "-c";
	argv[2] = buf;
	argv[3] = 0;

	switch(rfork(RFNOTEG|RFPROC|RFFDG)) {
	case -1:
		fprint(2, "can't fork\n");
		break;
	case 0:
		/* set user to none */
		f = open("/dev/user", OWRITE);
		if(f < 0) exits("/dev/user");
		write(f, "none", 4);
		close(f);
		exec("/bin/rc", argv);
		break;
	default:
		wait(&w);
		if(w.msg[0]) fprint(2,"%s\n", w.msg);
		break;
	}
}




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1998-08-16 12:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-08-16 12:34 [9fans] a curious process forsyth
  -- strict thread matches above, loose matches on Subject: below --
1998-08-16  6:02 arisawa

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).