question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error writing to history when broadcasting input to multiple terminals

See original GitHub issue

Environment data

PS version: 6.0.4
PSReadline version: 2.0.0-beta2
OS: Windows 10, Version 1703 (Build 15063.1209)

Steps to reproduce or exception report

  1. Open multiple instances of PowerShell in a terminal emulator which supports split panes and broadcasts (e.g.: ConEmu)
  2. Open three splits, resulting in four total open panes.
  3. Turn on broadcasting (ctrl+shift+G for ConEmu)
  4. Enter a command such as ls and press the Enter key.

Expected behavior

The command runs in all panes and no error is thrown

Actual behavior

The command runs in all panes, but errors will be thrown stating that the history file could not be written to because it is being used by another process

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
lzybkrcommented, Aug 24, 2018

In theory, the retry logic is already implemented, see here.

Based on the error, it seems like something is holding on to the file handle outside the mutex - so either I’m missing a using statement, or there is a side effect accessing the file that missed.

0reactions
sleighsoftcommented, Sep 10, 2019

This also happens when you programmatically open two terminals at the same time. This can be done with the “Terminals Manager” extension of VSCode, for example. You just configure two or more terminals and “Run Terminals” It will then throw Error reading or writing history file 'C:\Users\...\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt': The process cannot access the file 'C:\Users\...\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt' because it is being used by another process.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Preserve bash history in multiple terminal windows
Because when PROMPT_COMMAND is executed the history from all other Bash sessions are integrated in the history of the current session.
Read more >
Broadcast input to several terminals
As I see it, it seems relatively simple, it sends the input you send to one terminal to all others. How would you...
Read more >
Support broadcast input? · Issue #2634 · microsoft/terminal
Hey just as a feeler for folks following in this thread - How much demand is there for broadcasting to a subset of...
Read more >
Bash history handling with multiple terminals
I tried with export PROMPT_COMMAND='history -a; history -r' and I got some strange history line numbers in terminal - after issuing some command ......
Read more >
How to send a command to all panes in tmux?
Have you tried following in tmux window with multiple panes. Ctrl-B : setw synchronize-panes on clear history.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found