File:  [Research Unix] / researchv10no / cmd / hang.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:21:34 2018 UTC (8 years, 1 month ago) by root
Branches: belllabs, MAIN
CVS tags: researchv10, HEAD
researchv10 Norman

#include <stdio.h>
#include <signal.h>
#include <sys/pioctl.h>

main(argc,argv)
int argc; char **argv;
{
	int pfd;
	char procnam[16];
	long mask = (1<<(SIGSTOP-1));
	FILE *ttyerr;

	ttyerr = fopen("/dev/tty", "w");
	if (argc <= 1) {
		if( ttyerr )
			fprintf(ttyerr,"Usage: %s cmd [args...]\n",*argv);
		exit(1);
	}
	sprintf(procnam,"/proc/%05d",getpid());
	if ((pfd=open(procnam,0)) < 0) {
		if( ttyerr )
			fprintf(ttyerr,"cannot open %s\n",procnam);
		exit(1);
	}
	ioctl(pfd,PIOCSMASK,&mask);
	ioctl(pfd,PIOCSEXEC,0);
	close(pfd);
	if( ttyerr ){
		fprintf(ttyerr,"%s\n",procnam);
		fclose(ttyerr);
	}
	execvp(argv[1], argv+1);
	perror(argv[1]);
	exit(1);
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.