---
title: wps-linux 8259 Segmentation fault
date: 2018-07-20 23:35:55
tags: ["linux", "wps", "solution"]
---
# Problem
执行 **sudo dnf localinstall wps......rpm** 安装 WPS,接着输入 **wps**/**et**/**wpp**启动 WPS,可能会发生如以下错误:
```bash
/usr/bin/wps: line 38: 8259 Segmentation fault (core dumped) ${gInstallPath}/office6/${gApp} ${gOptExt} ${gOpt} "$@"
```
# Analysis
实际上是因为 WPS 中的设计主题使用的是 GTK+,需要手动指定,否则将会报错。
```bash
wps -style GTK+
```
但是这样显得比较麻烦。
通过`vim /usr/bin/wps`,`vim /usr/bin/wpp`,`vim /usr/bin/et`发现 wps 执行的真正命令,可以在启动之时添加
```bash
...
function run()
{
oldPwd="${PWD}"
if [ -e "${gInstallPath}/office6/${gApp}" ] ; then
if [ 1 -eq ${gDaemon} ]; then
nohup ${gInstallPath}/office6/${gApp} ${gOpt} > /dev/null 2>&1 &
else
${gInstallPath}/office6/${gApp} ${gOptExt} ${gOpt} "$@" // 这里才是真正运行的command,只需要在末尾添加 -style GTK+即可
fi
else
echo "${gApp} does not exist!"
fi
}
...
```
# Solution
为方便修改内容,使用 sed 命令进行替换,也可用 vim 手动修改。
```bash
sudo sed -i 's/${gOpt} \"$@\"$/${gOpt} \"$@\" -style GTK+/g' /usr/bin/wps;
sudo sed -i 's/${gOpt} \"$@\"$/${gOpt} \"$@\" -style GTK+/g' /usr/bin/wpp;
sudo sed -i 's/${gOpt} \"$@\"$/${gOpt} \"$@\" -style GTK+/g' /usr/bin/et;
```
wps-linux 8259 Segmentation fault