494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
|
length: (size_t)length
{
#ifndef _WIN32
if (_writePipe[1] == -1 || _atEndOfStream)
@throw [OFWriteFailedException exceptionWithObject: self
requestedLength: length];
if (write(_writePipe[1], buffer, length) < length)
@throw [OFWriteFailedException exceptionWithObject: self
requestedLength: length
errNo: errno];
#else
DWORD ret;
if (length > UINT32_MAX)
@throw [OFOutOfRangeException exception];
if (_writePipe[1] == NULL || _atEndOfStream)
@throw [OFWriteFailedException exceptionWithObject: self
requestedLength: length];
if (!WriteFile(_writePipe[1], buffer, (DWORD)length, &ret, NULL) ||
ret < length) {
int errNo = 0;
if (GetLastError() == ERROR_BROKEN_PIPE)
errNo = EPIPE;
@throw [OFWriteFailedException exceptionWithObject: self
requestedLength: length
|
>
>
>
|
|
|
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
|
length: (size_t)length
{
#ifndef _WIN32
if (_writePipe[1] == -1 || _atEndOfStream)
@throw [OFWriteFailedException exceptionWithObject: self
requestedLength: length];
if (length > SSIZE_MAX)
@throw [OFOutOfRangeException exception];
if (write(_writePipe[1], buffer, length) != (ssize_t)length)
@throw [OFWriteFailedException exceptionWithObject: self
requestedLength: length
errNo: errno];
#else
DWORD ret;
if (length > UINT32_MAX)
@throw [OFOutOfRangeException exception];
if (_writePipe[1] == NULL || _atEndOfStream)
@throw [OFWriteFailedException exceptionWithObject: self
requestedLength: length];
if (!WriteFile(_writePipe[1], buffer, (DWORD)length, &ret, NULL) ||
ret != (DWORD)length) {
int errNo = 0;
if (GetLastError() == ERROR_BROKEN_PIPE)
errNo = EPIPE;
@throw [OFWriteFailedException exceptionWithObject: self
requestedLength: length
|
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
|
#ifndef _WIN32
if (_readPipe[0] != -1)
close(_readPipe[0]);
if (_writePipe[1] != -1)
close(_writePipe[1]);
if (_pid != -1) {
kill(_pid, SIGKILL);
waitpid(_pid, &_status, WNOHANG);
}
_pid = -1;
_readPipe[0] = -1;
_writePipe[1] = -1;
#else
|
|
|
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
|
#ifndef _WIN32
if (_readPipe[0] != -1)
close(_readPipe[0]);
if (_writePipe[1] != -1)
close(_writePipe[1]);
if (_pid != -1) {
kill(_pid, SIGTERM);
waitpid(_pid, &_status, WNOHANG);
}
_pid = -1;
_readPipe[0] = -1;
_writePipe[1] = -1;
#else
|