This function is used in the uncommon cases where a running application wishes to disconnect from the host server but continue to execute. The host I/O system is shut down in the same way as when an application terminates. All file handles (including stdin, stdout, and stderr) are closed and you must make no further reference to them. You should ensure that your application does not have any connections with the host when this call is made (such as connections made by user-defined service clusters).
The parameter wait has two possible values:
|
1
|
Disconnect and wait for a reply from the server. The call returns only when the server has been reconnected and a Notify message sent.
|
|
0
|
Disconnect and return immediately.
|
The most common use of this function have wait=1. This reopens stdin, stdout, and stderr when the Notify message is received from the server, allowing the use of I/O functions such as printf.
Typical usage would be as follows:
#include <stdio.h>
extern void disconnect_server(int);
main() {
printf("Disconnecting the server\n");
disconnect_server(1);
printf("Server is connected again\n");
}
|