alibaba / alibaba/arthas

执行bg命令后退出当前session

Open
#2,985 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
37.5k
Forks
7.6k
Avg merge
1d 22h
Merged PRs (30d)
4

Description

- [x] 我已经在 [issues](https://github.com/alibaba/arthas/issues) 里搜索,没有重复的issue。

### 环境信息

* `arthas-boot.jar` 或者 `as.sh` 的版本: v4.0.4
* Arthas 版本: v4.0.4
* 操作系统版本: win11
* 目标进程的JVM版本: jdk8
* 执行`arthas-boot`的版本: v4.0.4

### 重现问题的步骤

1. 执行命令: trace cn.com.beautyfarm.controller.SysUserController list &
2. 执行命令: jobs (获取后台运行id)
3. 执行命令: fg id号
4. 按下按键: ctrl+z
5. 执行命令: bg id号

### 期望的结果
该trace任务在后台继续运行,命令行窗口可以继续停留在arthas命令行控制界面

### 实际运行的结果

```
[10]*
Stopped trace cn.com.beautyfarm.controller.SysUserController list &
execution count : 3
start time : Sun Jan 19 00:11:18 CST 2025
timeout date : Mon Jan 20 00:11:18 CST 2025
session : 2907be26-1e14-4812-a651-f5f78eac3b03 (current)
[arthas@10304]$ bg 10
[arthas@10304]$ [10]*
Running trace cn.com.beautyfarm.controller.SysUserController list &
execution count : 3
start time : Sun Jan 19 00:11:18 CST 2025
timeout date : Mon Jan 20 00:11:18 CST 2025
session : 2907be26-1e14-4812-a651-f5f78eac3b03 (current)

Connection to host lost.

D:\arthas>
```

在发生以上问题后,我使用telnet localhost 3658 重新建立连接后, 查看jobs,任务仍在运行. 再次执行fg命令,提示:
```
[arthas@10304]$ jobs
[10]
Running trace cn.com.beautyfarm.controller.SysUserController list &
execution count : 3
start time : Sun Jan 19 00:11:18 CST 2025
timeout date : Mon Jan 20 00:11:18 CST 2025
session : 2907be26-1e14-4812-a651-f5f78eac3b03
[arthas@10304]$ fg 10
job 10 doesn't belong to this session, so can not fg it
```

Contributor guide

Open the contributing guide

Research direction

Start by tracing the CLI handling for the `bg` command and session ownership of jobs. Reproduce the listed Windows/JDK 8 sequence with `trace`, `jobs`, `fg`, Ctrl-Z, and `bg`; done means the Arthas prompt remains connected and the job can be brought to the foreground in the appropriate session.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.