正在显示
3 个修改的文件
包含
14 行增加
和
1 行删除
| @@ -21,6 +21,7 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | @@ -21,6 +21,7 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
| 21 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | 21 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 22 | */ | 22 | */ |
| 23 | /** | 23 | /** |
| 24 | +@see: http://google-perftools.googlecode.com/svn/trunk/doc/cpuprofile.html | ||
| 24 | config srs with gperf(to make gperftools): | 25 | config srs with gperf(to make gperftools): |
| 25 | ./configure --with-gperf --jobs=3 | 26 | ./configure --with-gperf --jobs=3 |
| 26 | set the pprof path if not set: | 27 | set the pprof path if not set: |
| @@ -21,6 +21,7 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | @@ -21,6 +21,7 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
| 21 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | 21 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 22 | */ | 22 | */ |
| 23 | /** | 23 | /** |
| 24 | +@see: http://google-perftools.googlecode.com/svn/trunk/doc/heap_checker.html | ||
| 24 | config srs with gperf(to make gperftools): | 25 | config srs with gperf(to make gperftools): |
| 25 | ./configure --with-gperf --jobs=3 | 26 | ./configure --with-gperf --jobs=3 |
| 26 | set the pprof path if not set: | 27 | set the pprof path if not set: |
| @@ -56,8 +57,12 @@ void global_leak() { | @@ -56,8 +57,12 @@ void global_leak() { | ||
| 56 | global_leak_imp(); | 57 | global_leak_imp(); |
| 57 | } | 58 | } |
| 58 | 59 | ||
| 60 | +bool loop = true; | ||
| 59 | void handler(int sig) { | 61 | void handler(int sig) { |
| 60 | - exit(0); | 62 | + // we must use signal to notice the main thread to exit normally. |
| 63 | + if (sig == SIGINT) { | ||
| 64 | + loop = false; | ||
| 65 | + } | ||
| 61 | } | 66 | } |
| 62 | int main(int argc, char** argv) { | 67 | int main(int argc, char** argv) { |
| 63 | signal(SIGINT, handler); | 68 | signal(SIGINT, handler); |
| @@ -65,10 +70,16 @@ int main(int argc, char** argv) { | @@ -65,10 +70,16 @@ int main(int argc, char** argv) { | ||
| 65 | global_leak(); | 70 | global_leak(); |
| 66 | printf("press CTRL+C if you want to abort the program.\n"); | 71 | printf("press CTRL+C if you want to abort the program.\n"); |
| 67 | sleep(3); | 72 | sleep(3); |
| 73 | + if (!loop) { | ||
| 74 | + return 0; | ||
| 75 | + } | ||
| 68 | 76 | ||
| 69 | explicit_leak(); | 77 | explicit_leak(); |
| 70 | printf("press CTRL+C if you want to abort the program.\n"); | 78 | printf("press CTRL+C if you want to abort the program.\n"); |
| 71 | sleep(3); | 79 | sleep(3); |
| 80 | + if (!loop) { | ||
| 81 | + return 0; | ||
| 82 | + } | ||
| 72 | 83 | ||
| 73 | return 0; | 84 | return 0; |
| 74 | } | 85 | } |
| @@ -21,6 +21,7 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | @@ -21,6 +21,7 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
| 21 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | 21 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 22 | */ | 22 | */ |
| 23 | /** | 23 | /** |
| 24 | +@see: http://google-perftools.googlecode.com/svn/trunk/doc/heapprofile.html | ||
| 24 | config srs with gperf(to make gperftools): | 25 | config srs with gperf(to make gperftools): |
| 25 | ./configure --with-gperf --jobs=3 | 26 | ./configure --with-gperf --jobs=3 |
| 26 | set the pprof path if not set: | 27 | set the pprof path if not set: |
-
请 注册 或 登录 后发表评论