strace
प्रोसेस और सिस्टम
इस्तेमाल
strace [-f] -p <pid>किसी प्रक्रिया के हर सिस्टम कॉल को छापता है, इससे दिखता है वह कहाँ अटकी है; आउटपुट stderr पर जाता है, इसलिए `2>&1` से मोड़ें, ptrace अनुमति (आम तौर पर sudo) चाहिए, और यह केवल Linux पर है (macOS में dtruss)।
आम विकल्प
| विकल्प | अर्थ |
|---|---|
| -p <pid> | Attach to a process that is already running. |
| -f | Follow child processes and threads too. |
| -e trace=openat,connect | Only the syscalls you care about. |
| -s 200 | Show 200 characters of each string instead of the default 32. |
| -o <file> | Write to a file, since output goes to stderr. |
| -c | A summary count per syscall instead of every line. |
| -tt | Timestamps with microseconds, to see where the time went. |
उदाहरण
strace -f -e trace=openat ./app 2>&1 | grep configFind which config file it actually reads.
sudo strace -p 1234 -s 200See what a stuck process is waiting on.
sudo dtruss -p 1234The macOS counterpart; needs elevated privileges and often SIP changes.
क्या चल रहा है और क्या मशीन खा रहा है। मारने से पहले पहचानना क्रम है।
कैसे पढ़ें
- बड़े कोष्ठक [ ] उस हिस्से को दिखाते हैं जिसे छोड़ा जा सकता है।
- तीन बिंदु … का मतलब है एक से ज़्यादा दिए जा सकते हैं।
- विकल्पों में बड़े-छोटे अक्षर मायने रखते हैं — कुछ कमांड में -r और -R अलग काम करते हैं।
आम सवाल
Q. strace क्या करता है?
किसी प्रक्रिया के हर सिस्टम कॉल को छापता है, इससे दिखता है वह कहाँ अटकी है; आउटपुट stderr पर जाता है, इसलिए `2>&1` से मोड़ें, ptrace अनुमति (आम तौर पर sudo) चाहिए, और यह केवल Linux पर है (macOS में dtruss)।
Q. इसे कैसे लिखें?
strace [-f] -p <pid> — बड़े कोष्ठक वह हिस्सा दिखाते हैं जो छोड़ा जा सकता है।
Q. कितने विकल्प जानने लायक़ हैं?
यहाँ 7 दिए हैं; पूरी सूची man strace में है। यह कमांड प्रोसेस और सिस्टम में आती है।
मिलती-जुलती कमांड
man पेज: man strace