【问题标题】:Opening an existing process打开现有流程
【发布时间】:2026-01-20 18:20:12
【问题描述】:

我通过远程连接 (xrdp) 在 Linux 中使用 Eclipse。我的互联网断开了,所以在 Eclipse 运行时我与服务器断开了连接。

现在我再次登录,并执行“top”命令,我可以看到 eclipse 正在运行并且仍在我的用户名下。

有什么方法可以让这个过程重新回到我的视图中(我不想杀死它,因为我正在检查大量代码)?再次登录后,它没有显示在底部面板上。

这是“顶部”输出:

/home/mclouti% top
top - 08:32:31 up 43 days, 13:06, 29 users,  load average: 0.56, 0.79, 0.82
Tasks: 447 total,   1 running, 446 sleeping,   0 stopped,   0 zombie
Cpu(s):  6.0%us,  0.7%sy,  0.0%ni, 92.1%id,  1.1%wa,  0.1%hi,  0.1%si,  0.0%st
Mem:   3107364k total,  2975852k used,   131512k free,    35756k buffers
Swap:  2031608k total,    59860k used,  1971748k free,   817816k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
13415 mclouti   15   0  964m 333m  31m S 21.2 11.0  83:12.96 eclipse
16040 mclouti   15   0  2608 1348  888 R  0.7  0.0   0:00.12 top
31395 mclouti   15   0 29072  20m 8524 S  0.7  0.7 611:08.08 Xvnc
 2583 root      20   0  898m 2652 1056 S  0.3  0.1 139:26.82 automount
28990 postgres  15   0 13564  868  304 S  0.3  0.0  26:33.36 postgres
28995 postgres  16   0 13808 1248  300 S  0.3  0.0   6:54.95 postgres
31440 mclouti   15   0  3072 1592 1036 S  0.3  0.1   6:01.54 gam_server
    1 root      15   0  2072  524  496 S  0.0  0.0   0:03.00 init
    2 root      RT  -5     0    0    0 S  0.0  0.0   0:04.53 migration/0
    3 root      34  19     0    0    0 S  0.0  0.0   0:00.04 ksoftirqd/0
    4 root      RT  -5     0    0    0 S  0.0  0.0   0:00.00 watchdog/0
    5 root      RT  -5     0    0    0 S  0.0  0.0   0:01.72 migration/1
    6 root      34  19     0    0    0 S  0.0  0.0   0:00.07 ksoftirqd/1
    7 root      RT  -5     0    0    0 S  0.0  0.0   0:00.00 watchdog/1
    8 root      RT  -5     0    0    0 S  0.0  0.0   0:04.33 migration/2
    9 root      34  19     0    0    0 S  0.0  0.0   0:00.05 ksoftirqd/2

【问题讨论】:

  • 看起来您正在运行 vnc - 为什么不尝试再次连接,它应该会从您中断的地方继续。
  • 这就是这个线程的全部意义......它不会回来......

标签: linux eclipse unix rdp


【解决方案1】:

这是一个很长的尝试,但你可以试试这个来自this thread的小程序

#include <stdio.h>
#include <stdlib.h>
#include <X11/Xlib.h>

int main(int argc, char **argv)
{
if ( argc != 2 ) {
printf("Usage:\n\ttotop <window id>\n");
return 1;
}

Display *dsp = XOpenDisplay(NULL);

long id = strtol(argv[1], NULL, 16);
XRaiseWindow ( dsp, id );
XSetInputFocus ( dsp, id, RevertToNone, CurrentTime );

XCloseDisplay ( dsp );

return 0;
}

你可以编译它:

$ c++ totop.cpp -L/usr/X11R6/lib -lX11 -o totop

我假设你将它保存在“totop.cpp”中。

有问题我不知道如何解决:
如果窗口位于另一个虚拟桌面中,则此程序不起作用。
这里又出现了一个问题:如何将窗口发送到当前桌面?

您可以使用 xwininfo 获取窗口 ID。
使用这个程序调用Eclipse的一个小脚本:

#!/bin/bash
if ps -A | grep eclipse; then # if Eclipse already launched
  id=$(xwininfo -name "Eclipse" | grep id: | awk "{ print \$4 }")
  totop $id
else # launch Eclipse
  eclipse
fi

【讨论】: