1#!/bin/sh
2
3# busybox' getty does this itself, util-linux' agetty needs extra help
4getty="/sbin/getty"
5case $(readlink -f "${getty}") in
6    */busybox*)
7        ;;
8    *)
9        if [ -x "/usr/bin/setsid" ] ; then
10            setsid="/usr/bin/setsid"
11        fi
12        options=""
13        ;;
14esac
15
16if [ -e /sys/class/tty/$2 -a -c /dev/$2 ]; then
17	${setsid:-} ${getty} ${options:-} -L $1 $2 $3
18else
19    # Prevent respawning to fast error if /dev entry does not exist
20    sleep 1000
21fi
22