MCPcopy Create free account
hub / github.com/Tencent/libco / SetAndGetEnv

Function SetAndGetEnv

example_setenv.cpp:35–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33 int iRoutineID;
34};
35void SetAndGetEnv(int iRoutineID)
36{
37 printf("routineid %d begin\n", iRoutineID);
38
39 //use poll as sleep
40 poll(NULL, 0, 500);
41
42 char sBuf[128];
43 sprintf(sBuf, "cgi_routine_%d", iRoutineID);
44 int ret = setenv("CGINAME", sBuf, 1);
45 if (ret)
46 {
47 printf("%s:%d set env err ret %d errno %d %s\n", __func__, __LINE__,
48 ret, errno, strerror(errno));
49 return;
50 }
51 printf("routineid %d set env CGINAME %s\n", iRoutineID, sBuf);
52
53 poll(NULL, 0, 500);
54
55 char* env = getenv("CGINAME");
56 if (!env)
57 {
58 printf("%s:%d get env err errno %d %s\n", __func__, __LINE__,
59 errno, strerror(errno));
60 return;
61 }
62 printf("routineid %d get env CGINAME %s\n", iRoutineID, env);
63}
64
65void* RoutineFunc(void* args)
66{

Callers 1

RoutineFuncFunction · 0.85

Calls 3

pollFunction · 0.85
setenvFunction · 0.85
getenvFunction · 0.85

Tested by

no test coverage detected