logger: fix sd_backtrace()

- restructure the code
- check fgets and readlink retval to mute the gcc warning
- fix resource leak that doesn't call pclose().
- use MAX_PATH for path

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>