Mail Archives: cygwin/2014/09/18/17:32:19
X-Recipient: | archive-cygwin AT delorie DOT com
|
DomainKey-Signature: | a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
|
| :list-unsubscribe:list-subscribe:list-archive:list-post
|
| :list-help:sender:mime-version:message-id:from:to:subject
|
| :content-type:date; q=dns; s=default; b=pDMWCX7FEoEnaUEwX+SMB+Q5
|
| SicrFdPUdV3PqCkIJJPCINRYRJMowf3lKmGfgsPMUCb6OeIPipWk7SDZqw/yBHbF
|
| zRG2PUlOMdt3IBPYo3oT00WP9h1mbd07z8ljAFjj85fmCN6BjDeFEfnZKryfJW0z
|
| 0GUEne28mBGdHtJhGu0=
|
DKIM-Signature: | v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
|
| :list-unsubscribe:list-subscribe:list-archive:list-post
|
| :list-help:sender:mime-version:message-id:from:to:subject
|
| :content-type:date; s=default; bh=WYGNUZe2trx5kqvrKpWzGVFhPJc=; b=
|
| uJKPV9/e0Dtg9v6F3ZPlvNJ3MW+WKf39cz9JGXm7vC2fPBf0vqmA3UvGXvkVmaww
|
| +EvEM/SRVCrgqo+3E0A82QAj48rpEfKI2+a++s6yE5oc5MzkO9IZDrMuWUOsP4a8
|
| uDrakRtTnxGCUiITLkZLJb4oFnhJ5EAkRV05WdSrx/Q=
|
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm
|
List-Id: | <cygwin.cygwin.com>
|
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com>
|
List-Archive: | <http://sourceware.org/ml/cygwin/>
|
List-Post: | <mailto:cygwin AT cygwin DOT com>
|
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
|
Sender: | cygwin-owner AT cygwin DOT com
|
Mail-Followup-To: | cygwin AT cygwin DOT com
|
Delivered-To: | mailing list cygwin AT cygwin DOT com
|
Authentication-Results: | sourceware.org; auth=none
|
X-Virus-Found: | No
|
X-Spam-SWARE-Status: | No, score=0.6 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2
|
X-HELO: | mout.gmx.com
|
MIME-Version: | 1.0
|
Message-ID: | <trinity-176f4072-a859-498d-856f-e82eff480fc9-1411075916250@3capp-mailcom-lxa05>
|
From: | "Pierre Bogossian" <bogossian AT mail DOT com>
|
To: | cygwin AT cygwin DOT com
|
Subject: | Bad interaction between cygwin and ProcessBuilder when redirecting stdout
|
Date: | Thu, 18 Sep 2014 23:31:56 +0200
|
Sensitivity: | Normal
|
X-UI-Out-Filterresults: | notjunk:1;
|
--rehcsedm-16eb3a98-2b15-439d-ac03-0a81fecdc1a8
Content-Type: text/plain; charset=UTF-8
Hi,
I'm trying to use ProcessBuilder to execute cygwin programs.
ProcessBuilder is a Java API to run command lines.
The problem I'm dealing with is that redirecting the stdout (or stderr) of a cygwin program to a file in append mode doesn't work.
The file is not written.
If I do the same with a normal windows program (not a cygwin one), it works. So it seems to be a cygwin related issue.
If I redirect the stdout of the cygwin program to a file in write mode (instead of append mode), it does work too.
Here's the groovy code I've used for testing:
/////////////////////
dir = "C:\\\\pbtest\\\\";
logFile = dir + "foo.txt";
ProcessBuilder pb = new ProcessBuilder()
.command("sh", "writer.sh")
.directory(new File(dir));
// redirect stdout to a file in write mode
//pb.redirectOutput(ProcessBuilder.Redirect.to(new File(logFile)));
// redirect stdout to a file in append mode
pb.redirectOutput(ProcessBuilder.Redirect.appendTo(new File(logFile)));
pb.start();
/////////////////////
Where the script writer.sh just echoes a line on stdout.
I've used "Process Monitor" to trace the accesses that are made to foo.txt both in the "append" and in the "write" cases.
I've attached the two trace files to this mail.
You'll notice that in the "append" case, sh doesn't even do the "WriteFile" call.
The other difference between the two traces is the option list java is passing to the "CreateFile" call:
In the "write" case:
Desired Access: Generic Write, Read Attributes, Disposition: OverwriteIf
In the "append" case:
Desired Access: Append Data/Add Subdirectory/Create Pipe Instance, Write EA, Read Attributes, Write Attributes, Read Control, Synchronize, Disposition: OpenIf
NB: I'm running cygwin 1.7.32 (32-bit) on Windows 7 (64-bit). The Java version is 1.7.0_40.
Regards,
Pierre
--rehcsedm-16eb3a98-2b15-439d-ac03-0a81fecdc1a8
Content-Type: text/plain
Content-Disposition: attachment; filename=pb_append.txt
16:02:51,0072167 java.exe 5612 CreateFile C:\pbtest\foo.txt SUCCESS Desired Access: Append Data/Add Subdirectory/Create Pipe Instance, Write EA, Read Attributes, Write Attributes, Read Control, Synchronize, Disposition: OpenIf, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Write, AllocationSize: 0, OpenResult: Opened
16:02:51,0952435 sh.exe 3192 DeviceIoControl C:\pbtest\foo.txt INVALID PARAMETER Control: 0x1b0050 (Device:0x1b Function:20 Method: 0)
16:02:51,0952795 sh.exe 3192 QueryNameInformationFile C:\pbtest\foo.txt SUCCESS Name: \pbtest\foo.txt
16:02:51,0969548 sh.exe 3192 CreateFile C:\pbtest\foo.txt SUCCESS Desired Access: Read EA, Read Attributes, Read Control, Disposition: Open, Options: Open For Backup, Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
16:02:51,0970670 sh.exe 3192 QueryInformationVolume C:\pbtest\foo.txt SUCCESS VolumeCreationTime: 31/01/2013 21:13:11, VolumeSerialNumber: 5003-210E, SupportsObjects: True, VolumeLabel: CSC ESOE
16:02:51,0970883 sh.exe 3192 QueryAttributeInformationVolume C:\pbtest\foo.txt SUCCESS FileSystemAttributes: Case Preserved, Case Sensitive, Unicode, ACLs, Compression, Named Streams, Object IDs, Reparse Points, Sparse Files, Quotas, Transactions, 0x3c00000, MaximumComponentNameLength: 255, FileSystemName: NTFS
16:02:51,0971132 sh.exe 3192 QueryNetworkOpenInformationFile C:\pbtest\foo.txt SUCCESS CreationTime: 18/09/2014 13:38:07, LastAccessTime: 18/09/2014 15:43:47, LastWriteTime: 18/09/2014 16:02:25, ChangeTime: 18/09/2014 16:02:25, AllocationSize: 01/01/1601 02:00:00, EndOfFile: 01/01/1601 02:00:00, FileAttributes: A
16:02:51,0971351 sh.exe 3192 CloseFile C:\pbtest\foo.txt SUCCESS
16:02:51,1362820 sh.exe 3192 CloseFile C:\pbtest\foo.txt SUCCESS
--rehcsedm-16eb3a98-2b15-439d-ac03-0a81fecdc1a8
Content-Type: text/plain
Content-Disposition: attachment; filename=pb_write.txt
16:02:25,7924624 java.exe 5612 CreateFile C:\pbtest\foo.txt SUCCESS Desired Access: Generic Write, Read Attributes, Disposition: OverwriteIf, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Write, AllocationSize: 0, OpenResult: Overwritten
16:02:25,9070108 sh.exe 6712 DeviceIoControl C:\pbtest\foo.txt INVALID PARAMETER Control: 0x1b0050 (Device:0x1b Function:20 Method: 0)
16:02:25,9070460 sh.exe 6712 QueryNameInformationFile C:\pbtest\foo.txt SUCCESS Name: \pbtest\foo.txt
16:02:25,9094194 sh.exe 6712 CreateFile C:\pbtest\foo.txt SUCCESS Desired Access: Read EA, Read Attributes, Read Control, Disposition: Open, Options: Open For Backup, Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
16:02:25,9095628 sh.exe 6712 QueryInformationVolume C:\pbtest\foo.txt SUCCESS VolumeCreationTime: 31/01/2013 21:13:11, VolumeSerialNumber: 5003-210E, SupportsObjects: True, VolumeLabel: CSC ESOE
16:02:25,9095844 sh.exe 6712 QueryAttributeInformationVolume C:\pbtest\foo.txt SUCCESS FileSystemAttributes: Case Preserved, Case Sensitive, Unicode, ACLs, Compression, Named Streams, Object IDs, Reparse Points, Sparse Files, Quotas, Transactions, 0x3c00000, MaximumComponentNameLength: 255, FileSystemName: NTFS
16:02:25,9096107 sh.exe 6712 QueryNetworkOpenInformationFile C:\pbtest\foo.txt SUCCESS CreationTime: 18/09/2014 13:38:07, LastAccessTime: 18/09/2014 15:43:47, LastWriteTime: 18/09/2014 16:02:25, ChangeTime: 18/09/2014 16:02:25, AllocationSize: 01/01/1601 02:00:00, EndOfFile: 01/01/1601 02:00:00, FileAttributes: A
16:02:25,9096323 sh.exe 6712 CloseFile C:\pbtest\foo.txt SUCCESS
16:02:25,9332531 sh.exe 6712 WriteFile C:\pbtest\foo.txt SUCCESS Offset: 0, Length: 15, Priority: Normal
16:02:25,9335022 sh.exe 6712 CloseFile C:\pbtest\foo.txt SUCCESS
--rehcsedm-16eb3a98-2b15-439d-ac03-0a81fecdc1a8
Content-Type: text/plain; charset=us-ascii
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
--rehcsedm-16eb3a98-2b15-439d-ac03-0a81fecdc1a8--
- Raw text -