Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 Mar 2017 16:51:39 -0400
From:      Ernie Luzar <luzar722@gmail.com>
To:        "Igor R." <freebsd@str.komkon.org>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: command line history broken in 11.0
Message-ID:  <58D1925B.8050500@gmail.com>
In-Reply-To: <alpine.BSF.2.20.1703211310410.12389@tissa.komkon.org>
References:  <alpine.BSF.2.20.1703211310410.12389@tissa.komkon.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Igor R. wrote:
> 
> It is not something that I've tried to do, but here is an idea:
>    "reboot & ; exit".
> The rational is that by doing this you would detach the standard output
> of the "reboot" process, and that will allow the exit to complete.
> 
> If that doesn't help, you can think about redirecting the stdout
> (and as the next step, - stderr) in that command.
> 
> HTH!
> 
> PS. I just looked at the source code, and I suspect that the difference 
> in the behavior in 10.3 and 11.0 (or 11.0.1) might be related to these 
> changes:
> Just before 10.3 release, this change was introduced to /bin/csh:
> https://svnweb.freebsd.org/base?view=revision&revision=296976
> and then quickly reversed. by Revision 297204.
> https://svnweb.freebsd.org/base?view=revision&revision=297204
> You can see that revision 296976 had weird side effects:
> "causes strange effects like for example SIGTERM not
> being delivered to rc(8) scripts on shutdown albeit these use sh(1),
> if csh(1) or tcsh(1) are used as login shell of root."
> 
> 
> At the same time, soon after 10.3-release was split from HEAD, that 
> change was reversed in HEAD as well, but in addition to that (Revision 
> 297672) a different call (fork) was introduced:
> https://svnweb.freebsd.org/base?view=revision&revision=297673
> https://svnweb.freebsd.org/base/head/bin/csh/config_p.h?r1=297673&r2=297672&pathrev=297673 
> 
> 
> Maybe that change also had some side effects (like what you see), but 
> just less severe or less noticeable, - so it "worked" for 11.0*-release.
> 
> Assuming my guess is correct, I'd recommend you filing a bug report (pr),
> so that it is documented - and that can bring it to the attention of the 
> core team.
> https://bugs.freebsd.org/bugzilla/enter_bug.cgi
> 
> 
> 
> On Mon, 20 Mar 2017 14:05-0400, Ernie Luzar wrote:
> 
>> On 10.3 I had the current session saving the command line history when 
>> issuing
>> the shutdown, halt, and reboot command by using these alias commands 
>> that I
>> added to the .cshrc file of my logged in user account.
>>
>> alias sd    "exit && shutdown now"
>> alias sdp    "exit && shutdown -p now"
>> alias rboot     "exit && reboot"
>> alias stop      "exit && halt"
>>
>> Now after doing a clean install of 11.0 and using the same .cshrc file 
>> the
>> rboot and stop alias commands no longer save the current history. They 
>> act
>> like the exit command is not getting executed. The sd and sdp alias 
>> commands
>> are working as expected.
>>
>> When existing from a session terminal by issuing the exit command does 
>> still
>> save the current history.
>>
>> Is there an alternate method I can use?


Thank you Igor.

Your reply hit the mail on the head. You have proved there is a reason 
for the different between 10.3 and 11.0. I now know its not me screwing 
something up.

I've been a Freebsd user since release 3.0. Over time I noticed that the 
  shell command line history was NEVER being updated so I would see the 
history from the previous session merged into the old .history file the 
next time I started the host. It was not existing the shell and logging 
on the next day, instead I would issue halt or shutdown -p now command.

During the 10.x series some time I posted a question to the questions 
list about this behavior. To make a long story short, the solution at 
that time was to do it this way and it was working fine.

   alias rboot     "exit && reboot"
   alias stop      "exit && halt"

Then along comes 11.0 and it stopped working, I tried many different 
combinations and nothing worked. It was Polytropon who gave me the 
pointer I needed. Even though I had reread the shutdown man page a few 
times, I never really understood what the meaning of the -o flag was 
really talking about. I recoded my alias commands like this

   alias sd        "shutdown -o now"
   alias sdp       "shutdown -po now"
   alias rboot     "shoutdown -ro now"
   alias stop      "shutdown -ho now"

Low and be hold, Now the shell is given a chance to close down normally 
which allows the shell .history file to be updated. My world is happy 
again. This also explains why sometimes at shutdown my database gets 
corrupted

To my way of thinking this -o should be the default behavior instead of 
how it is now. This default behavior is now in violation of the original 
intention for using the shutdown command in the first place, which is to 
allow running tasks to close down cleanly saving databases from becoming 
corrupted.

It would be best if halt and reboot commands were deprecated and removed 
from the base system leaving the shutdown command the only way to bring 
down the system, aside from the power button. The shutdown -o mode 
should become the default mode. Then "shutdown -r now" becomes the 
replacement for the "reboot" command and "shutdown -h now" becomes the 
replacement for "halt" command. Their is never a technical need where 
it's necessary to just terminate everything thats running. This concept 
of terminating all running tasks is a legacy leftover from the first BSD 
version that now needs to be corrected. With todays powerful computers 
there is no noticeable lag in allowing tasks to shutdown cleanly.

To address people who may have reboot or halt inbedded in some scripts, 
the reboot command could be an alias for "shutdown -r now" and halt an 
alias for "shutdown -h now".

I think a PR is needed here to get this problem documented. It surely 
effects every user of FreeBSD.

Now if I have missed something or mis-understood something, I sure would 
like to hear about it before I submit a PR on this. Even an 
acknowledgment that I got it correct would be good to hear.

Thanks to everyone who replied.






Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?58D1925B.8050500>