3

I check the openvt manual by running "man openvt" command, and i found doshell(8) under "SEE ALSO" section:

enter image description here

But there's no manual if i do "man 8 doshell":

enter image description here

I checked the online manual at http://linux.about.com/library/cmd/blcmdl1_openvt.htm, the doshell(8) is not a link:

enter image description here

I found someone mentioned "(There is also the ancient doshell(8)", answered at https://stackoverflow.com/questions/21428158/how-to-send-broadcast-message-to-console-in-linux-from-c-program

enter image description here

Just a question out of my curiosity, is there any place i can find information about doshell(8)?

3

I'm not sure (it has been a while) but it looks to me that is a reference to the old Linux routine (1992): ftp://ftp2.de.freebsd.org/pub/linux/tsx-11/sources/usr.bin/doshell.c:

#include <stdio.h>
#include <sys/file.h>
#include <errno.h>

extern char *sys_errlist[];

main(int argc, char *argv[])
{

    if (argc != 3) {
    fprintf(stderr, "usage: doshell <ttyname> <shellname> &\n");
    exit(1);
    }

    /* close down fd's */
    close(0);
    close(1);
    close(2);

    /* detach from parent process's group */
    setsid();

    /* open new tty */
    if (open(argv[1], O_RDWR, 0) == -1)
    exit(2);
    dup(0);
    dup(0);
    execlp(argv[2], "-", 0);
    /* should appear on new tty...: */
    fprintf(stderr, "can't exec shell: %s\n", sys_errlist[errno]);
    exit(3);
}

It might also refer to the older Minux routine: http://users.sosdg.org/~qiyong/mxr/source/commands/mail/mail.c#L702

void doshell(command)
char *command;
{
  int waitstat, pid;
  char *shell;

  if (NULL == (shell = getenv("SHELL"))) shell = SHELL;

  if ((pid = fork()) < 0) {
        perror("mail: couldn't fork");
        return;
  } else if (pid != 0) {        /* parent */
        wait(&waitstat);
        return;
  }

  /* Child */
  setgid(getgid());
  setuid(getuid());
  umask(oldmask);

  execl(shell, shell, "-c", command, (char *) NULL);
  fprintf(stderr, "can't exec shell\n");
  exit(127);
} 

Both routines seem to have the functionality as described in the stackoverflow answer, and it doesn't seem unlikely the first derived from the second.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.