473,574 Members | 3,011 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how dump a program which is running in memory

hi
I have written a service running backgroud to do something in linux.
unfortunately$ B!$(BI deleted the source code by mistake, and I can still
see the process running background using "ps aux" :

username 13820 0.0 0.0 60368 2964 ? S Aug20 0:33
python ./UpdateJobStatus .py
I wonder if there is some way to dump the programme
"UpdateJobStatu s.py" and get the source code back?
Thanks a lot.
Sep 11 '08 #1
2 2611
ruqiang826 wrote:
hi
I have written a service running backgroud to do something in linux.
unfortunatelyï¼ ŒI deleted the source code by mistake, and I can still
see the process running background using "ps aux" :

username 13820 0.0 0.0 60368 2964 ? S Aug20 0:33
python ./UpdateJobStatus .py
I wonder if there is some way to dump the programme
"UpdateJobStatu s.py" and get the source code back?
Often, there is a way by accessing /proc/{pid}/fd/

But I believe you're out of luck with this method because apparently the
Python interpreter closes the source file after parsing it.

You can still try to find an undeletion utility for your filesystem.
Avoid writing to disk in the meantime to not overwrite the deleted file
accidentally, of course. There's such a utility for ext2, but I don't
know if that works ok with ext3. For other filesystems, I have no idea.

-- Gerhard

Sep 11 '08 #2
On Thu, 11 Sep 2008 02:31:23 -0700 (PDT), ruqiang826 wrote:
I have written a service running backgroud to do something in linux.
unfortunately$ B!$(BI deleted the source code by mistake, and I can still
see the process running background using "ps aux" :

username 13820 0.0 0.0 60368 2964 ? S Aug20 0:33
python ./UpdateJobStatus .py
I wonder if there is some way to dump the programme
"UpdateJobStatu s.py" and get the source code back?
The best way to do it would be to undelete the file,
just as Gerhard suggested.

If you remember any line (or piece) of code from the UpdateJobStatus .py
file you can try to dump the /dev/mem to the hard disk, and then grep
through it (remember that you need root priviledges to access /dev/mem).

I tried it with this code:

http://www.mail-archive.com/li******.../msg03696.html

with a small modification of this line:
nvram = (strtol(argv[1], 0, 0)) << 16;
changed to:
nvram = (strtol(argv[1], 0, 0));

After compilation I just did:
../a.out 0x0 0xffffffff memdump
to get the memory dump.

I am not a memory expert, but 0xffffffff should be enough
for <= 4GB of RAM. If you got more, increase it.

And to make it clear: I do not recommend this way of sorting
things out :)

--
Regards,
Wojtek Walczak,
http://tosh.pl/gminick/
Sep 11 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
6799
by: Ravi Tallury | last post by:
Hi We are having issues with our application, certain portions of it stop responding while the rest of the application is fine. I am attaching the Java Core dump. If someone can let me know what the issue is. Thanks Ravi
3
6189
by: Nick Craig-Wood | last post by:
I've just discovered that my python (Python 2.3.4 from debian package 2.3.4-1 running on debian testing x86 + linux 2.4.26) core dumps when I set recursionlimit very high and do lots of recursion. Eg $ python -c 'import sys; sys.setrecursionlimit(100000) def f(): return f() f()' Segmentation fault (core dumped)
2
3699
by: John Liu | last post by:
I've two questions, they may or may not be related - 1. I copied the entire data directory from postgreSQL 7.3.2 (AIX4.3) to the installation postgreSQL 7.3.4 (AIX5.1), the same filesystem setup. I didn't do an dump/reload process since the copy process is faster. Is it OK to take this shortcut in postgreSQL? any side-effects? 2. The...
1
1388
by: QQ | last post by:
I can sense that I get wrong with char *name, however, how to fix it ? Thanks a lot! int Roamer_Create(const char *dbname) { char *name; printf("dbname is %s\n",dbname); sprintf(name,"CREATE DATABASE %s",dbname); printf("command is %s\n",name);
9
3243
by: Microsoft News Server | last post by:
Hi, I am currently having a problem with random, intermittent lock ups in my ASP.net application on our production server (99% CPU usage by 3 threads, indefinately). I currently use IIS Debug Tools to do a memory dump of the app when the lock up occurs, however the stack information is not very useful. I have just put a new build of our...
6
11280
by: Soeren Gerlach | last post by:
Hi, some weeks ago I started to develop an application using Postgresql the first time. I'm running 7.4.3 on a Linux box with a plain 2.6.7 kernel, the storage is handled by 5 SATA disks, managed by a 3ware controller and using a xfs filesystem. The DB server is a 3 Ghz P4 with 4 Gig of Ram, so the machine is quite fast for most purposes I...
5
2733
by: Allin Cottrell | last post by:
A. Suppose my program mallocs and populates an array of structs of a fixed size apiece. For example, something like: struct foo { int i; double x; char s; }; We want to save this work and re-read it later. One solution
2
3792
by: erfan | last post by:
Hi,comp.c: I try to learn malloc,facing a problem like this: -------- #include<unistd.h> #include<stdlib.h> #include<stdio.h> int main(void) {
7
1533
by: Just_a_fan | last post by:
I have a program which runs fine here (created in VB9). I publish it to my web site for download & install. It runs on some computers (one or two) but not others. When it does not run, it causes a reporting and submission window to pop up. It seems something is missing. This program was converted from a VB6 original piece. ...
0
7726
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8052
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8234
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7815
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6452
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3740
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3749
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2243
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1339
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.