Freeing ttyS0 for loopback test - application hangs/blocks
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Freeing ttyS0 for loopback test - application hangs/blocks
I run Montavista 2.6.18 on ARM/TI.
I need to use external loopback on ttyS0, which is linux console by default.
The application will test the whole serial track via loopback.
It is started from initd (script in rc3.d) and getty start in iniittab is allowed as "once" only (not respawn).
The reduced initialization code looks like:
Now, the questions/problems:
1. When the first line of the initialization code system("killall getty") is active, application hangs at this point (never exits system() call), if the loopback is closed. Otherwise it passes OK, the test starts, and even passes, when I close the loopback later.
2. Removing system() call allows the application to initialize and pass to the first write(fd,"Test text",10), which hangs.
Again the same - starting with loopback opened and closing it later after makes everything working as required.
Any hints/recommendations/help will be highly appreciated...
You have to disable ttys0 from being started for login.
The problem is that the init process will restart the getty process as soon as it exits. The only to way to prevent that is to stop init from starting it. And that requires you to change the configuration for init. Otherwise you are in a race condition between init respawining getty before you get your test started.
I'm not familiar with Montavista, but usually the console terminals are started in /etc/inittab.
For such testing, I would suggest using an unused runlevel that doesn't initialize a getty ttys0 (try to have an alternate though). This runlevel can then be used to run your diagnostics. When they have finished, have the diagnostic script switch run levels to something else.
Thank you, JPollard (Jonathan Pollard? My Respect!
May be you did not noticed that I start getty in inittab with option "once" instead of "respawn" in hope that this will allow one login, if required. Therefore I do kill getty, when the testing starts. Otherwise, one will still be able to login...
But you point to the right way - I tried to remove getty at all and found that after this everything works fine!
SO, the issue is - how to allow getty to run when there is no need in testing (most of the work).
That was why I mentioned using an "unused" run level. Going to that run level would stop the getty from running, when the tests would be done, the last thing the script would do is switch runlevels to the default. To start the test, just tell init to switch to the test run level. The current login would be terminated (getty execs login, login execs shell, so killing the process that was started by getty will terminate the login).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.