libarchive / libarchive

Multi-format archive and compression library

Home Page:http://www.libarchive.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tar option `w` does not work on Windows

jet2jet opened this issue · comments

commented

Basic Information

  • Version of libarchive: 3.7.4 (or HEAD of libarchive repo)
  • How you obtained it: build from source, and a binary bundled in Windows (version is 3.6.2)
  • Operating system and version: Windows 11 (10.0.22621.3447)
  • What compiler and/or IDE you are using (include version): Visual Studio 2022 (17.7.0) / Microsoft C/C++ Compiler 19.37.32822

Description of the problem you are seeing:

  • When executing tar cwf test.tar *.*, tar prompts for confirmation but immediately prints Keyboard read failed.

How the libarchive developers can reproduce your problem:

  • Simply type tar cwf test.tar *.* in Windows
commented

In tar/util.c yes function:

l = read(2, buff, sizeof(buff) - 1);

tar reads input from stderr (fd = 2), but in Windows it seems to be not supported. (I think another implementation such as using stdin explicitly might be necessary because of pipe support.)

CC: @stoeckmann , @DHowett -- Any thoughts?

Oh, wow. Yes, I don't think reading stderr is supported on Windows. Funny enough, I am also the owner for the console subsystem :)

If you want to be resilient to piping in stdin, there are some annoying platform specific things you'll need to do. I'll write up a quick sample (perhaps a PR!)