X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f X-Recipient: djgpp AT delorie DOT com X-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=z/5npJqFXV4o+cN+PV5/I4DENUfOlXFSQc8Lbob3154=; b=i7uj7Xu1eGpHuCm3kq56FnrMeJFZUm1in7K+4tRTTsKzIbWs1X5PbH+6vgY46Y8nrp VoZ9dem5zMcha3cxumin7sbNqsXCgOpIArvoUDzpqIpxHYWDTUg05vWJkopjuQAVSj1Q fs6dNq5wZwYePga2ypEnal2tp0CObv3LgQnEi8BE2PK1Bkf6gQagE0iXmEAzVErXQcJw d+ryqcJ4L0/9QHuNHxpiFmzkiQMfmuojWeMj82ahH+qNMbJ5mE2BvWP4h4JSy8Gwatgx zlh1GZk6R7ZIRXgOvsrD2qdSnS3HvUtBKkSvhjUDle2sl5nTSLoHKzLnScCH/eL27soL 13WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=z/5npJqFXV4o+cN+PV5/I4DENUfOlXFSQc8Lbob3154=; b=mdH4WdKJIwdr2Eg3wRvLwbQIg9P0mRMx2Q5yndm7tLn+tY1oE2yxyiqoNOEbOJS+Jx prDFd27mb9ZyBCJWkHU21EV5fsig6q6/WB8vibspn7JuzxhbYousX+1+Jt4Ubizq6MYv MlqxPdyxkaDQDmeKLNVn/Rnz/dofddlPncWwMOeDZsSWH7NB/TdoczJeneiSp95AMpje Uj5HMcieCH+U6qqvBHdmLaEOhGg3Ud8iksRdwQ3NkZck7kyGvzvsHUUa6DW/kAK9Mj43 SIxzWxBDEADVFl2WuYsU0nTPD0TdMYH+7h32a2XI8VqPbkboFJ5Y3sMt1lidTf42wvix WYGA== X-Gm-Message-State: AOAM5323AtFDiLzSD1tbyYjWx3X5+2xvPtWllSbtknF/Ln3sEhLWUx4a 6RvU2Mf0hjXcAXPw4YKaa5ffaNJavnpwegvfm3yjga8g X-Google-Smtp-Source: ABdhPJybtnOQn3Z5ggJshUi3gcWzBA9WmftcBA6entmpjSGw7cPXa/jjxY5Z/aQeC2C1WyU5fRrKWj9LC6uzrK7Mawc= X-Received: by 2002:aca:d4d1:: with SMTP id l200mr13357705oig.119.1616852348914; Sat, 27 Mar 2021 06:39:08 -0700 (PDT) MIME-Version: 1.0 From: "Ozkan Sezer (sezeroz AT gmail DOT com) [via djgpp AT delorie DOT com]" Date: Sat, 27 Mar 2021 16:39:08 +0300 Message-ID: Subject: issue with popen and reading from stdout To: djgpp AT delorie DOT com Content-Type: text/plain; charset="UTF-8" Reply-To: djgpp AT delorie DOT com The code is basically: p = popen(cmdline, "rb"); while ((n = fread(buf, 1, BUFLEN, p)) > 0) { fwrite(buf, 1, n, t); } pclose(p); ... where cmdline is like "unrar p -inul ponylips.rar". The "p" makes unrar to extract to stdout, -inul makes unrar to emit no messages. The issue is: Whatever I do, including inserting calls like setmode(fileno(stdout),O_BINARY), extracted file has 0x0a -> 0x0d 0x0a changes and corrupted. For what it's worth, manually running that cmd on the console itself, like "unrar p -inul ponylips.rar > ponylips.mod" gives the same result. Is this a thing with djgpp, or possibly something to do with unrar for dos? (The unrar version in question is v3.80 and is downloadable from https://www.rarlab.com/rar_add.htm which seems to be built using djppp.) -- O.S.