#include <sys/types.h> 
#include <sys/ioctl.h> 
#include <fcntl.h> 
#include <errno.h> 
#include <stdlib.h> 
#include <unistd.h> 
#include <stdio.h> 
#include <signal.h> 
/* Main program. */ 
int main(int argc, char **argv) 
{
 int fd; 
 int sleep_time; 
 /*  These TIOCM_* parameters are defined in 
  *   <linux/termios.h>, which
  *  is indirectly included here.
  */ 
 int dtr_bit = TIOCM_DTR; 
 int rts_bit = TIOCM_RTS; 
 int set_bits; 
 int flags; 
 int status, oldstat = -1; 
 int count = 0; 
 int pc; 
 if (argc < 3) {
  fprintf(stderr, "Usage: ar-2 <device> "
                  "<bits-to-set> <hold-time>\n"); 
  exit(1); 
 }
 /* Open monitor device. */ 
 if ((fd = open(argv[1], O_RDWR | O_NDELAY)) < 0) {
  fprintf(stderr, "ar-2: %s: %s\n", 
          argv[1], sys_errlist[errno]); 
  exit(1);
 }
 /* Get the bits to set from the command line. */ 
 sscanf(argv[2], "%d", &set_bits); 
 /* get delay time from command line. */ 
 sscanf(argv[3], "%d", &sleep_time); 
 ioctl(fd, TIOCMSET, &set_bits); 
 /* quite please */ 
 /* fprintf(stderr, "Setting %o.\n", set_bits); */ 
 sleep(sleep_time); 
 close(fd); 
}
