Last active
August 29, 2015 14:02
-
-
Save wateroot/282580109fd062b37d80 to your computer and use it in GitHub Desktop.
ExecPipeCmd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int ExecPipeCmd(char *szCmd) | |
| { | |
| FILE *pPipe = _popen(szCmd, "rt"); | |
| if (NULL == pPipe) { | |
| //Log("_popen functio fail.\n"); | |
| return -1; | |
| } | |
| int nRet = -1; | |
| CHAR szBuf[SOCK_BUF_SIZE] = {0}; | |
| while (fgets(szBuf, sizeof(szBuf), pPipe)) { | |
| //send buf info to master. | |
| nRet = send(g_hSock, szBuf, strnlen_s(szBuf, sizeof(szBuf)), 0); | |
| if(nRet < 0) { | |
| //Log("\nError occuerd while send data."); | |
| break; | |
| } | |
| ZeroMemory(szBuf, sizeof(szBuf)); | |
| } | |
| if (0 == _pclose(pPipe)) { | |
| return 0; | |
| } | |
| return -1; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment