home *** CD-ROM | disk | FTP | other *** search
- /* startmgr: Create a one-line window on the top line of the Unix-PC
- (7300/3B1) screen and start a program running in that window.
- Declare this window to be the Window Manager, which gives it control
- over the Suspend, Resume and Print keys. This is meant to be used to
- start newmgr, but can probably be adapted to be a fairly generic program
- starter. It was designed to mimic the observed operation of things like
- cron, smgr, etc.
-
- This software is Copyright (c) 1987 by Scott Hazen Mueller.
-
- Permission is hereby granted to copy, reproduce, redistribute or
- otherwise use this software as long as: there is no monetary
- profit gained specifically from the use or reproduction or this
- software, it is not sold, rented, traded or otherwise marketed, and
- this copyright notice is included prominently in any copy
- made.
-
- The author make no claims as to the fitness or correctness of
- this software for any use whatsoever, and it is provided as is.
- Any use of this software is at the user's own risk.
-
- (Copyright notice courtesy of News 2.11 :-)
-
- Additionally: you break it, you bought it. I've listed the problems
- that I know of in comments in the code; if you come up with fixes, I'd
- like to see them, but I'm not planning on supporting anything. It's
- "good enough"; that's all that I'm looking for. */
-
- #include <stdio.h>
- #include <sys/types.h>
- #include <wind.h>
- #include <sys/window.h>
- #include <fcntl.h>
- #include <termio.h>
-
- /* Parameters defining the window and the program for that window. You'll
- almost certainly have to change barprog to correspond with whatever
- directory you use for your local stuff.
-
- Note: WFLAGS was determined empirically, by looking at the flags for
- the AT&T-supplied smgr window. No guarantees here. */
-
- #define BARPROG "/usr/local/newmgr"
- #define WXSTART 0
- #define WYSTART 0
- #define WWIDTH 720
- #define WHEIGHT 12
- #define WFLAGS 257
-
- main()
- {
- int wd, dummy;
- struct uwdata winbar;
- struct utdata winname;
- struct termio bartty;
-
- winbar.uw_x = WXSTART;
- winbar.uw_y = WYSTART;
- winbar.uw_width = WWIDTH;
- winbar.uw_height = WHEIGHT;
- winbar.uw_uflags = WFLAGS;
- winname.ut_num = WTXTUSER;
-
- strcpy( winname.ut_text, "Invisible" );
- if ( fork() )
- exit( 0 );
- else {
-
- /* Setpgrp() cannot be called from processes associated with windows.
- From the manual. Since it's a cleaner model for the parent to redirect
- the child's stdin, stdout and stderr, we do that. We have to setpgrp(),
- or else the child would be killed when the process group leader exited. */
-
- fclose( stdin );
- fclose( stdout );
- fclose( stderr );
- setpgrp();
-
- /* Get a window, and set it up according to our parameters. Since stdin
- was closed above, wd gets to be stdin (roughly). */
-
- wd = open( "/dev/window", O_RDWR|O_EXCL, 0 );
- ioctl( wd, WIOCSETD, &winbar );
- ioctl( wd, WIOCSETTEXT, &winname );
- ioctl( wd, WIOCSYS, SYSWMGR );
- ioctl( wd, WIOCSYS, SYSPMGR );
-
- /* Set up the child's stdout and stderr to point at the window. */
-
- dup( wd );
- dup( wd );
-
- /* Set terminal parameters; after all, we'll want to read escape codes and
- other neat stuff. */
-
- ioctl( wd, TCGETA, &bartty );
- bartty.c_iflag &= ~IGNBRK;
- bartty.c_lflag &= ~( ICANON | ECHO );
-
- /* Read three characters at a time; 1 second timeout interval. Whether
- this really does anything, I don't know. */
-
- bartty.c_cc[4] = 3;
- bartty.c_cc[5] = 10;
- ioctl( wd, TCSETA, &bartty );
-
- /* Execute with no command line arguments. */
-
- execl( BARPROG, BARPROG, 0 );
- }
- }
-
-