Currently for one of my machines, I have it automatically starting X using rc.local. E.g by putting in the following line.

Code:

su -l myusername -c "xinit twm &"

Whilst this works pretty well, I seem to not be able to type anything on the keyboard (keypresses go to the ttyC0 console underneath instead). To hack around this I have to write a script that waits 10 seconds and then runs 'xinit twm'. With this then it seems to have expected behavior.

Yep, but it only a suggestion. The xinit application was designed to be run by a logged in end user, with both an attached tty/pty and a $HOME environment variable. It was not intented to be run by an rc(8) script at initialization time.

Like BSDfan666, I would recommend xdm. It is highly configurable, and designed for this purpose.

The issue with XDM is that the user would need to log in.
Ideally this machine is to be used as a permanently logged in terminal with a GUI and interactive application running. (twm was just a simple example)

I used to use FreeBSD for this (put a similar script in '/etc/rc.d' and it worked well), unfortunately OpenBSD better supports the hardware than FreeBSD, thus the change.

Is there a way to forcefully attach a tty/pty before I call xinit (or startx)?

On another note I am also concerned that my clone of CDE's dtlogin is going to have problems with OpenBSD because it uses a similar method of starting up.