Currently I have a program that runs and sleeps for 60 seconds. I get the PID of the program and I run "sudo gcore (PID of process)". But I am getting the message "gcore: insufficient privilege" in the terminal. I am not sure why this is happening and how to resolve this..
when I run "info gcore" I see that the format is:
gcore [-s] [-v] [-b size] [-o path | -c pathformat] pid
Using the above format, can any one also give an example of a gcore command that generates a core dump on a running process using the process id and saves that core dump to a specific file path?
Note: I also installed the home-brew version of gcore as told in another stack overflow post but that didn't help
Related
I'm trying to remotely launch and debug a new process with lldb without much success.
Attaching to an already launched process works well by running these commands:
process connect <url>
process attach -P gdb-remote --pid <pid>
But if I want debugserver to launch the executable by itself I'm running into troubles. Especially, I have no clue what arguments should I pass to target create.
According to this page LLDB "will transparently take care of [..] downloading the executable in order to be able to debug", yet target create seem to always require a local file. If I specify the remote file via -r I get either unable to open target file or remote --> local transfer without local path is not implemented yet errors. If I set the target to a local file (such as a local copy of the remote's loader executable) without using -r, then attempt to run process launch -p gdb-remote -s <remote path> LLDB will attempt running the local path on the remote machine and fail.
What are the correct commands I need to use in order to launch a remote process?
After contacting LLDB's mailing list Greg updated the documentation page, which now clearly explains what I have to do (Specifically I was missing the script lines, which appear to be the correct way to set the remote executable path)
I'm using a psuedo terminal, /bin/sh -i, by calling normal commands for posix_openpty() then fork(), in language C.
When I run from command line GUI terminal like this
$ ./MyTerminal
or
$ sudo ./MyTerminal
or as root like this
# ./MyTerminal
all works very good and as expected, no problems.
However, when I make a systemd service file like this, it works fine
[Service]
User=root
But when I try to get systemd to run it as normal user like this
[Service]
User=debian
THe first output for /bin/sh -i is
/bin/sh: 0: can't access tty; job control turned off $
And the terminal does not really work.
When I run /bin/bash, fork() w/posix_openpty() is returns me this, but the terminal generally works ok
bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell
Is such a weird prolem because when running outside of systemd everything works perfect. I see this problem in 1 other question but no clear solution. So what I have to change to make systemd run my file perfectly? Thanks for your help.
I currently have an Asus c300 chromebook. Since it doesn't have legacy boot, I'm using crouton to get a more standard command line environment. I was able to install gcc very easily in the chroot environment. It works very well under chroot.
Since the underlying hardware is the same, I thought the resulting executable should work for chromebook, without me being in the chroot environment. If true, I thought I could go into the chroot environment, compile whatever program I want/need, and exit back out to the regular environment and use it.
I tried it with a simple hello world program. When I tried to run the executable, I got the following error:
bash: ./a.out: Permission denied.
I tried to run it with sudo, and I get a similar error:
sudo: unable to execute ./a.out: Permission denied.
I even used su to login as root, and I still could not run the program (got the first error).
I thought su/sudo would override any kind of permission restriction. But, it's apparently not the case on the chromebook.
What am I missing? Is what I want to do possible?
EDIT: File permission was already set to 777.
You might simply have to change the permissions of the file or check the files ownership. umask determines weather or not a file that is created gets execute permissions by default. What does -ls -lat on the file reveal?
Also try running
chmod +x ./a.out
You can find more details of error with strace command
use:
strace ./a.out and check output.
I suppose you have different env (path and LD_library_path) under the chroot.
Does lldb have an equivalent for gdb's shell command to run external commands from the prompt? (see How can I execute external commands from the gdb command prompt?)
This might be what you're looking for...
(lldb) help platform shell
Run a shell command on a the selected platform. This command takes 'raw'
input (no need to quote stuff).
Syntax: platform shell <shell-command>
Command Options Usage:
platform shell [-t <value>]
-t <value> ( --timeout <value> )
Seconds to wait for the remote host to finish running the command.
IMPORTANT NOTE: Because this command takes 'raw' input, if you use any
command options you must use ' -- ' between the end of the command options
and the beginning of the raw input.
(lldb) platform shell ls
If you get:
error: unable to run a remote command without a platform
Try this command to see if you need to give lldb more context:
(lldb) platform status
If you are debugging on a real iOS ARM device, this will show Platform: remote-ios. If you are on a simulator, you will get your macOS related info.
nscd service crashed without a core dump file.
ulimit -c is unlimited.
Someone says that that's because nscd use "setuid" when the "server-user" is set in /etc/nscd.conf.
Then I added a "#" to delete it at the beginning of the "server-user" line in /etc/nscd.conf then restart the service.
Now it runs as root which could be checked by "ps -ef | grep nscd".
However, the following commands still could not make nscd to generate a core dump file:
kill -ABRT nscd-pid
or kill -s SIGSEGV nscd-pid
Who can tell me why and how? Thanks in advance!
resolved it myself. That's because nscd is called with "daemon nscd ..." in /etc/init.d/nscd script, however the daemon function in /etc/init.d/functions modify the core dump file size to be 0, so even if issuing "ulimit -c unlimited" at the beginning of "/etc/init.d/nscd" could not make sence.