You are not logged in.

#1 2012-07-06 13:33:25

fijit
Member
Registered: 2012-07-06
Posts: 24

Change in login/logout behaviour?

Hi all,
I used to start my wm automatically from tty login using the following in .profile:

 if [[ ! $DISPLAY && -z `pgrep -u $USER xinit` ]]; then
    xinit &
    exit
fi 

This would automatically start the wm and then logout, freeing up the tty, but the X session would persist.

Since the recent update to util-linux and shadow, this no longer works because the X session is killed upon logout. This is not specific to X, any process launched to the background in .bashrc or .profile is killed on logout. On the other hand, simply executing

 xinit & exit 

at the console gives the previous behaviour where the X session persists after logout.

Does anyone know why this has changed and if it is possible to go back to the old behaviour?

Last edited by fijit (2012-07-06 13:34:05)

Offline

#2 2012-07-06 14:32:11

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,422
Website

Re: Change in login/logout behaviour?

- Nevermind -

I still have what you describe as the "old" behavior.  When did this change for you?

Last edited by Trilby (2012-07-06 14:34:17)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2012-07-06 14:42:19

guelfi
Member
From: /home/guelfi
Registered: 2011-07-01
Posts: 111

Re: Change in login/logout behaviour?

exec xinit
xinit & disown
exit

The first one only works if it's the last one in the script.

Last edited by guelfi (2012-07-06 14:44:07)

Offline

#4 2012-07-06 15:40:35

fijit
Member
Registered: 2012-07-06
Posts: 24

Re: Change in login/logout behaviour?

Trilby wrote:

- Nevermind -

I still have what you describe as the "old" behavior.  When did this change for you?

This changed during the last update of util-linux (2.21.2-3) and shadow (4.1.5.1-1). Downgrading those packages restores the old behaviour.

guelfi wrote:
exec xinit
xinit & disown
exit

The first one only works if it's the last one in the script.

Thanks for the suggestions. The first doesn't quite do what I want, which is to logout but leave X running. Instead, the user is logged out when the X session is killed. The second seems to make no difference.

I have found that adding nohup seems to allow what I want to do. Still, I'm curious about why this has changed.

Offline

#5 2012-07-06 21:15:22

DSpider
Member
From: Romania
Registered: 2009-08-23
Posts: 2,273

Re: Change in login/logout behaviour?

Post your /etc/inittab.


"How to Succeed with Linux"

I have made a personal commitment not to reply in topics that start with a lowercase letter. Proper grammar and punctuation is a sign of respect, and if you do not show any, you will NOT receive any help (at least not from me).

Offline

#6 2012-07-06 22:44:10

fijit
Member
Registered: 2012-07-06
Posts: 24

Re: Change in login/logout behaviour?

DSpider wrote:

Post your /etc/inittab.

It's not meaningfully changed from default

#
# /etc/inittab
#

#  Runlevels:
#    0    Halt
#    1(S)	Single-user
#    2    Not used
#    3    Multi-user
#    4    Not used
#    5    X11
#    6    Reboot

## Only one of the following two lines can be uncommented!
# Boot to console
id:3:initdefault:
# Boot to X11
#id:5:initdefault:

rc::sysinit:/etc/rc.sysinit
rs:S1:wait:/etc/rc.single
rm:2345:wait:/etc/rc.multi
rh:06:wait:/etc/rc.shutdown
su:S:wait:/sbin/sulogin -p

# -8 options fixes umlauts problem on login
c1:2345:respawn:/sbin/agetty --noclear -8 -s 38400 tty1 linux
c2:2345:respawn:/sbin/agetty -8 -s 38400 tty2 linux
c3:2345:respawn:/sbin/agetty -8 -s 38400 tty3 linux
#c4:2345:respawn:/sbin/agetty -8 -s 38400 tty4 linux
#c5:2345:respawn:/sbin/agetty -8 -s 38400 tty5 linux
#c6:2345:respawn:/sbin/agetty -8 -s 38400 tty6 linux

# Serial Virtual Console for KVM and others VMs
#s0:2345:respawn:/sbin/agetty -8 -s 9600 ttyS0 linux

# Hypervisor Virtual Console for Xen and KVM
#h0:2345:respawn:/sbin/agetty -8 -s 38400 hvc0 linux

ca::ctrlaltdel:/sbin/shutdown -t3 -r now

# Example lines for starting a login manager
#x:5:respawn:/usr/bin/xdm -nodaemon
#x:5:respawn:/usr/sbin/gdm -nodaemon
#x:5:respawn:/usr/bin/kdm -nodaemon
#x:5:respawn:/usr/bin/slim >/dev/null 2>&1

# End of file

Offline

#7 2012-07-07 10:53:44

guelfi
Member
From: /home/guelfi
Registered: 2011-07-01
Posts: 111

Re: Change in login/logout behaviour?

xinit & disown
exit

works for me with both bash and zsh.

Offline

#8 2012-07-07 16:23:00

fijit
Member
Registered: 2012-07-06
Posts: 24

Re: Change in login/logout behaviour?

guelfi wrote:
xinit & disown
exit

works for me with both bash and zsh.

Well, not for me. This is fine in any other script but not if included in .bashrc or .profile.

Offline

#9 2012-07-07 18:35:38

DSpider
Member
From: Romania
Registered: 2009-08-23
Posts: 2,273

Re: Change in login/logout behaviour?

I think you mean ~/.bash_profile, not "~/.profile". Maybe that's why it's not working.

~/.bashrc is for aliases and such.


http://www.cyberciti.biz/faq/change-bash-profile/

~/.bashrc file runs every time you open a new non-login bash shell such as xterm / aterm
~/.bash_profile runs only with login shells i.e when you first log in into system.


"How to Succeed with Linux"

I have made a personal commitment not to reply in topics that start with a lowercase letter. Proper grammar and punctuation is a sign of respect, and if you do not show any, you will NOT receive any help (at least not from me).

Offline

#10 2012-07-07 19:05:45

kachelaqa
Member
Registered: 2010-09-26
Posts: 216

Re: Change in login/logout behaviour?

Before the util-linux-2.21.2-3 update, I was doing manual logins like this:

# ~/.bash_profile

nohup xinit -- /usr/bin/X -br -nolisten tcp vt7 &> /dev/null &
sleep 5
exit

# or, alternatively:

xinit -- /usr/bin/X -br -nolisten tcp vt7 &> /dev/null &
disown -h
sleep 5
exit
# ~/.xinitrc

exec ck-launch-session dbus-launch --exit-with-session openbox-session

But, as several others have also found, the update has broken that, as the X session will now just get killed on exit.

I'm pretty sure that the source of the problem is the change from using shadow/login to util-linux/login, as the two implementations obviously don't behave in precisely the same way.

Anyway, I have found that the original behaviour can be restored by making use of the setsid command (also from util-linux):

# ~/.bash_profile

setsid xinit -- /usr/bin/X -br -nolisten tcp vt7 &> /dev/null &
sleep 5
exit

Offline

#11 2012-07-07 19:51:20

fijit
Member
Registered: 2012-07-06
Posts: 24

Re: Change in login/logout behaviour?

DSpider wrote:

I think you mean ~/.bash_profile, not "~/.profile". Maybe that's why it's not working.

~/.bashrc is for aliases and such.

man bash wrote:

When bash is invoked as an interactive login shell ..., it looks for ~/.bash_profile,  ~/.bash_login,  and ~/.profile, in that order

and .bashrc is called from (my) .profile. .bashrc not be the "correct" place for login commands but it works.

kachelaqa wrote:

I'm pretty sure that the source of the problem is the change from using shadow/login to util-linux/login, as the two implementations obviously don't behave in precisely the same way.
Anyway, I have found that the original behaviour can be restored by making use of the setsid command (also from util-linux):

I guess that is it. Strangely, nohup still works for me, but setsid is probably cleaner.

Offline

Board footer

Powered by FluxBB