Skip to content

Instantly share code, notes, and snippets.

View guangxuanliu's full-sized avatar

guangxuan guangxuanliu

View GitHub Profile
@guangxuanliu
guangxuanliu / log.cpp
Created June 12, 2023 11:51
以追加模式写日志文件,指针
#include <iostream>
#include <sstream>
#include <fstream>
using namespace std;
int main()
{
std::ofstream outfile;
outfile.open("example.txt", std::ios_base::app); // 以追加模式打开文件
@guangxuanliu
guangxuanliu / deadlock.md
Last active November 6, 2022 13:05
gdb调试死锁技巧
@guangxuanliu
guangxuanliu / getpid.sh
Created October 30, 2022 14:56
鼠标点选指定窗口获取窗口PID
xprop _NET_WM_PID | cut -d' ' -f3
#define m 16
char buffer[m] = {0};
int index = 0;
void fillBuffer(const char *buf, int n)
{
if(index + n <= m)
{
memcpy(buffer + index, buf, n);
index += n;
@guangxuanliu
guangxuanliu / pstack
Created October 15, 2022 09:43
Linux下的pstack工具
#!/bin/sh
if test $# -ne 1; then
echo "Usage: `basename $0 .sh` <process-id>" 1>&2
exit 1
fi
if test ! -r /proc/$1; then
echo "Process $1 not found." 1>&2
exit 1
fi