Skip to content

Commit ecc91ae

Browse files
committed
Remove trailing whitespace
1 parent 86db281 commit ecc91ae

File tree

1 file changed

+138
-138
lines changed

1 file changed

+138
-138
lines changed

docs/c-runtime-library/reference/popen-wpopen.md

Lines changed: 138 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ ms.custom: ""
44
ms.date: "11/04/2016"
55
ms.reviewer: ""
66
ms.suite: ""
7-
ms.technology:
7+
ms.technology:
88
- "cpp-standard-libraries"
99
ms.tgt_pltfrm: ""
1010
ms.topic: "article"
11-
apiname:
11+
apiname:
1212
- "_popen"
1313
- "_wpopen"
14-
apilocation:
14+
apilocation:
1515
- "msvcrt.dll"
1616
- "msvcr80.dll"
1717
- "msvcr90.dll"
@@ -24,16 +24,16 @@ apilocation:
2424
- "ucrtbase.dll"
2525
- "api-ms-win-crt-stdio-l1-1-0.dll"
2626
apitype: "DLLExport"
27-
f1_keywords:
27+
f1_keywords:
2828
- "tpopen"
2929
- "popen"
3030
- "wpopen"
3131
- "_popen"
3232
- "_wpopen"
3333
- "_tpopen"
34-
dev_langs:
34+
dev_langs:
3535
- "C++"
36-
helpviewer_keywords:
36+
helpviewer_keywords:
3737
- "tpopen function"
3838
- "pipes, creating"
3939
- "_popen function"
@@ -46,7 +46,7 @@ caps.latest.revision: 15
4646
author: "corob-msft"
4747
ms.author: "corob"
4848
manager: "ghogen"
49-
translation.priority.ht:
49+
translation.priority.ht:
5050
- "cs-cz"
5151
- "de-de"
5252
- "es-es"
@@ -62,136 +62,136 @@ translation.priority.ht:
6262
- "zh-tw"
6363
---
6464
# _popen, _wpopen
65-
Creates a pipe and executes a command.
66-
65+
Creates a pipe and executes a command.
66+
6767
> [!IMPORTANT]
68-
> This API cannot be used in applications that execute in the Windows Runtime. For more information, see [CRT functions not supported with /ZW](http://msdn.microsoft.com/library/windows/apps/jj606124.aspx).
69-
70-
## Syntax
71-
72-
```
73-
74-
FILE *_popen(
75-
const char *command,
76-
const char *mode
77-
);
78-
FILE *_wpopen(
79-
const wchar_t *command,
80-
const wchar_t *mode
81-
);
82-
```
83-
84-
#### Parameters
85-
*command*
86-
Command to be executed.
87-
88-
*mode*
89-
Mode of the returned stream.
90-
91-
## Return Value
92-
Returns a stream associated with one end of the created pipe. The other end of the pipe is associated with the spawned command's standard input or standard output. The functions return **NULL** on an error. If the error is an invalid parameter, such as if *command* or *mode* is a null pointer, or *mode* is not a valid mode, `errno` is set to `EINVAL`. See the Remarks section for valid modes.
93-
94-
For information about these and other error codes, see [_doserrno, errno, _sys_errlist, and _sys_nerr](../../c-runtime-library/errno-doserrno-sys-errlist-and-sys-nerr.md).
95-
96-
## Remarks
97-
The `_popen` function creates a pipe and asynchronously executes a spawned copy of the command processor with the specified string *command*. The character string *mode* specifies the type of access requested, as follows.
98-
99-
**"r"**
100-
The calling process can read the spawned command's standard output using the returned stream.
101-
102-
**"w"**
103-
The calling process can write to the spawned command's standard input using the returned stream.
104-
105-
**"b"**
106-
Open in binary mode.
107-
108-
**"t"**
109-
Open in text mode.
110-
68+
> This API cannot be used in applications that execute in the Windows Runtime. For more information, see [CRT functions not supported with /ZW](http://msdn.microsoft.com/library/windows/apps/jj606124.aspx).
69+
70+
## Syntax
71+
72+
```
73+
74+
FILE *_popen(
75+
const char *command,
76+
const char *mode
77+
);
78+
FILE *_wpopen(
79+
const wchar_t *command,
80+
const wchar_t *mode
81+
);
82+
```
83+
84+
#### Parameters
85+
*command*
86+
Command to be executed.
87+
88+
*mode*
89+
Mode of the returned stream.
90+
91+
## Return Value
92+
Returns a stream associated with one end of the created pipe. The other end of the pipe is associated with the spawned command's standard input or standard output. The functions return **NULL** on an error. If the error is an invalid parameter, such as if *command* or *mode* is a null pointer, or *mode* is not a valid mode, `errno` is set to `EINVAL`. See the Remarks section for valid modes.
93+
94+
For information about these and other error codes, see [_doserrno, errno, _sys_errlist, and _sys_nerr](../../c-runtime-library/errno-doserrno-sys-errlist-and-sys-nerr.md).
95+
96+
## Remarks
97+
The `_popen` function creates a pipe and asynchronously executes a spawned copy of the command processor with the specified string *command*. The character string *mode* specifies the type of access requested, as follows.
98+
99+
**"r"**
100+
The calling process can read the spawned command's standard output using the returned stream.
101+
102+
**"w"**
103+
The calling process can write to the spawned command's standard input using the returned stream.
104+
105+
**"b"**
106+
Open in binary mode.
107+
108+
**"t"**
109+
Open in text mode.
110+
111111
> [!NOTE]
112-
> If used in a Windows program, the `_popen` function returns an invalid file pointer that causes the program to stop responding indefinitely. `_popen` works properly in a console application. To create a Windows application that redirects input and output, see [Creating a Child Process with Redirected Input and Output](http://msdn.microsoft.com/library/windows/desktop/ms682499) in the Windows SDK.
113-
114-
`_wpopen` is a wide-character version of `_popen`; the *path* argument to `_wpopen` is a wide-character string. `_wpopen` and `_popen` behave identically otherwise.
115-
116-
### Generic-Text Routine Mappings
117-
118-
|Tchar.h routine|_UNICODE and _MBCS not defined|_MBCS defined|_UNICODE defined|
119-
|---------------------|--------------------------------------|--------------------|-----------------------|
120-
|`_tpopen`|`_popen`|`_popen`|`_wpopen`|
121-
122-
## Requirements
123-
124-
|Routine|Required header|
125-
|-------------|---------------------|
126-
|`_popen`|\<stdio.h>|
127-
|`_wpopen`|\<stdio.h> or \<wchar.h>|
128-
129-
For more compatibility information, see [Compatibility](../../c-runtime-library/compatibility.md).
130-
131-
## Libraries
132-
All versions of the [C run-time libraries](../../c-runtime-library/crt-library-features.md).
133-
134-
## Example
135-
136-
```
137-
// crt_popen.c
138-
/* This program uses _popen and _pclose to receive a
139-
* stream of text from a system process.
140-
*/
141-
142-
#include <stdio.h>
143-
#include <stdlib.h>
144-
145-
int main( void )
146-
{
147-
148-
char psBuffer[128];
149-
FILE *pPipe;
150-
151-
/* Run DIR so that it writes its output to a pipe. Open this
152-
* pipe with read text attribute so that we can read it
153-
* like a text file.
154-
*/
155-
156-
if( (pPipe = _popen( "dir *.c /on /p", "rt" )) == NULL )
157-
exit( 1 );
158-
159-
/* Read pipe until end of file, or an error occurs. */
160-
161-
while(fgets(psBuffer, 128, pPipe))
162-
{
163-
printf(psBuffer);
164-
}
165-
166-
/* Close pipe and print return value of pPipe. */
167-
if (feof( pPipe))
168-
{
169-
printf( "\nProcess returned %d\n", _pclose( pPipe ) );
170-
}
171-
else
172-
{
173-
printf( "Error: Failed to read the pipe to the end.\n");
174-
}
175-
}
176-
```
177-
178-
## Sample Output
179-
This output assumes that there is only one file in the current directory with a .c file name extension.
180-
181-
```
182-
Volume in drive C is CDRIVE
183-
Volume Serial Number is 0E17-1702
184-
185-
Directory of D:\proj\console\test1
186-
187-
07/17/98 07:26p 780 popen.c
188-
1 File(s) 780 bytes
189-
86,597,632 bytes free
190-
191-
Process returned 0
192-
```
193-
194-
## See Also
195-
[Process and Environment Control](../../c-runtime-library/process-and-environment-control.md)
196-
[_pclose](../../c-runtime-library/reference/pclose.md)
197-
[_pipe](../../c-runtime-library/reference/pipe.md)
112+
> If used in a Windows program, the `_popen` function returns an invalid file pointer that causes the program to stop responding indefinitely. `_popen` works properly in a console application. To create a Windows application that redirects input and output, see [Creating a Child Process with Redirected Input and Output](http://msdn.microsoft.com/library/windows/desktop/ms682499) in the Windows SDK.
113+
114+
`_wpopen` is a wide-character version of `_popen`; the *path* argument to `_wpopen` is a wide-character string. `_wpopen` and `_popen` behave identically otherwise.
115+
116+
### Generic-Text Routine Mappings
117+
118+
|Tchar.h routine|_UNICODE and _MBCS not defined|_MBCS defined|_UNICODE defined|
119+
|---------------------|--------------------------------------|--------------------|-----------------------|
120+
|`_tpopen`|`_popen`|`_popen`|`_wpopen`|
121+
122+
## Requirements
123+
124+
|Routine|Required header|
125+
|-------------|---------------------|
126+
|`_popen`|\<stdio.h>|
127+
|`_wpopen`|\<stdio.h> or \<wchar.h>|
128+
129+
For more compatibility information, see [Compatibility](../../c-runtime-library/compatibility.md).
130+
131+
## Libraries
132+
All versions of the [C run-time libraries](../../c-runtime-library/crt-library-features.md).
133+
134+
## Example
135+
136+
```
137+
// crt_popen.c
138+
/* This program uses _popen and _pclose to receive a
139+
* stream of text from a system process.
140+
*/
141+
142+
#include <stdio.h>
143+
#include <stdlib.h>
144+
145+
int main( void )
146+
{
147+
148+
char psBuffer[128];
149+
FILE *pPipe;
150+
151+
/* Run DIR so that it writes its output to a pipe. Open this
152+
* pipe with read text attribute so that we can read it
153+
* like a text file.
154+
*/
155+
156+
if( (pPipe = _popen( "dir *.c /on /p", "rt" )) == NULL )
157+
exit( 1 );
158+
159+
/* Read pipe until end of file, or an error occurs. */
160+
161+
while(fgets(psBuffer, 128, pPipe))
162+
{
163+
printf(psBuffer);
164+
}
165+
166+
/* Close pipe and print return value of pPipe. */
167+
if (feof( pPipe))
168+
{
169+
printf( "\nProcess returned %d\n", _pclose( pPipe ) );
170+
}
171+
else
172+
{
173+
printf( "Error: Failed to read the pipe to the end.\n");
174+
}
175+
}
176+
```
177+
178+
## Sample Output
179+
This output assumes that there is only one file in the current directory with a .c file name extension.
180+
181+
```
182+
Volume in drive C is CDRIVE
183+
Volume Serial Number is 0E17-1702
184+
185+
Directory of D:\proj\console\test1
186+
187+
07/17/98 07:26p 780 popen.c
188+
1 File(s) 780 bytes
189+
86,597,632 bytes free
190+
191+
Process returned 0
192+
```
193+
194+
## See Also
195+
[Process and Environment Control](../../c-runtime-library/process-and-environment-control.md)
196+
[_pclose](../../c-runtime-library/reference/pclose.md)
197+
[_pipe](../../c-runtime-library/reference/pipe.md)

0 commit comments

Comments
 (0)