Skip to content

Commit

Permalink
Add a minimal usage message.
Browse files Browse the repository at this point in the history
  • Loading branch information
nelhage committed Jan 20, 2011
1 parent cdc7f64 commit e2d8d67
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion reptyr.c
Expand Up @@ -106,10 +106,33 @@ void do_proxy(int pty) {
}
}

void usage(char *me) {
fprintf(stderr, "Usage: %s [-l | PID]\n", me);
}

int main(int argc, char **argv) {
struct termios saved_termios;
struct sigaction act;
int pty;
int do_attach = 1;

if (argc < 2) {
usage(argv[0]);
return 2;
}
if(argv[1][0] == '-') {
switch(argv[1][1]) {
case 'h':
usage(argv[0]);
return 0;
case 'l':
do_attach = 0;
break;
default:
usage(argv[0]);
return 1;
}
}

if ((pty = open("/dev/ptmx", O_RDWR|O_NOCTTY)) < 0)
die("Unable to open /dev/ptmx: %m");
Expand All @@ -118,7 +141,7 @@ int main(int argc, char **argv) {
if (grantpt(pty) < 0)
die("Unable to unlockpt: %m");

if (argc > 1) {
if (do_attach) {
pid_t child = atoi(argv[1]);
int err;
if ((err = attach_child(child, ptsname(pty)))) {
Expand Down

0 comments on commit e2d8d67

Please sign in to comment.